From 471d7b9420c17cd8aa032232d07f6f8b039ead13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 23 Dec 2024 13:46:13 +0100 Subject: [PATCH 01/43] refactor(core): Move Logger to `core` (no-changelog) (#12310) --- packages/@n8n/task-runner/src/start.ts | 2 +- packages/cli/package.json | 4 +- packages/cli/src/abstract-server.ts | 2 +- packages/cli/src/active-executions.ts | 2 +- packages/cli/src/active-workflow-manager.ts | 2 +- packages/cli/src/auth/auth.service.ts | 2 +- packages/cli/src/commands/base-command.ts | 2 +- .../src/commands/db/__tests__/revert.test.ts | 2 +- packages/cli/src/commands/db/revert.ts | 2 +- packages/cli/src/commands/worker.ts | 3 +- .../concurrency-control.service.ts | 2 +- packages/cli/src/config/index.ts | 25 ++++++---- .../cli/src/controllers/auth.controller.ts | 2 +- .../cli/src/controllers/e2e.controller.ts | 2 +- .../src/controllers/invitation.controller.ts | 2 +- packages/cli/src/controllers/me.controller.ts | 2 +- .../oauth1-credential.controller.test.ts | 2 +- .../oauth2-credential.controller.test.ts | 2 +- .../oauth/abstract-oauth.controller.ts | 3 +- .../cli/src/controllers/owner.controller.ts | 2 +- .../controllers/password-reset.controller.ts | 2 +- .../cli/src/controllers/users.controller.ts | 2 +- .../workflow-statistics.controller.ts | 2 +- packages/cli/src/crash-journal.ts | 3 +- packages/cli/src/credentials-overwrites.ts | 2 +- .../src/credentials/credentials.controller.ts | 2 +- .../src/credentials/credentials.service.ts | 3 +- .../repositories/execution.repository.ts | 3 +- .../databases/subscribers/user-subscriber.ts | 4 +- packages/cli/src/databases/types.ts | 3 +- .../src/databases/utils/migration-helpers.ts | 3 +- .../src/deprecation/deprecation.service.ts | 3 +- .../__tests__/source-control.service.test.ts | 3 +- .../source-control-export.service.ee.ts | 3 +- .../source-control-git.service.ee.ts | 2 +- .../source-control-helper.ee.ts | 2 +- .../source-control-import.service.ee.ts | 3 +- .../source-control-preferences.service.ee.ts | 3 +- .../source-control.service.ee.ts | 2 +- .../message-event-bus-destination-from-db.ts | 2 +- ...message-event-bus-destination-syslog.ee.ts | 3 +- .../message-event-bus-destination.ee.ts | 2 +- .../message-event-bus-log-writer.ts | 3 +- .../message-event-bus/message-event-bus.ts | 2 +- .../__tests__/save-execution-progress.test.ts | 2 +- .../restore-binary-data-id.ts | 3 +- .../save-execution-progress.ts | 3 +- .../shared/shared-hook-functions.ts | 2 +- .../execution-recovery.service.test.ts | 2 +- .../executions/execution-recovery.service.ts | 3 +- .../cli/src/executions/execution.service.ts | 2 +- .../external-secrets-manager.ee.ts | 3 +- .../aws-secrets/aws-secrets-manager.ts | 2 +- .../azure-key-vault/azure-key-vault.ts | 2 +- .../gcp-secrets-manager.ts | 2 +- .../src/external-secrets/providers/vault.ts | 2 +- packages/cli/src/help.ts | 4 +- packages/cli/src/ldap/ldap.service.ee.ts | 3 +- packages/cli/src/license.ts | 3 +- packages/cli/src/license/license.service.ts | 2 +- .../cli/src/load-nodes-and-credentials.ts | 2 +- packages/cli/src/logging/constants.ts | 3 -- packages/cli/src/logging/types.ts | 14 ------ packages/cli/src/manual-execution.service.ts | 3 +- .../src/push/__tests__/websocket.push.test.ts | 2 +- packages/cli/src/push/abstract.push.ts | 3 +- packages/cli/src/response-helper.ts | 3 +- ...nner-process-restart-loop-detector.test.ts | 2 +- .../__tests__/task-runner-process.test.ts | 2 +- packages/cli/src/runners/runner-ws-server.ts | 2 +- .../cli/src/runners/task-broker.service.ts | 2 +- .../cli/src/runners/task-runner-module.ts | 3 +- .../cli/src/runners/task-runner-process.ts | 2 +- .../cli/src/runners/task-runner-server.ts | 2 +- packages/cli/src/scaling/job-processor.ts | 3 +- .../cli/src/scaling/multi-main-setup.ee.ts | 3 +- .../src/scaling/pubsub/publisher.service.ts | 5 +- .../src/scaling/pubsub/subscriber.service.ts | 5 +- packages/cli/src/scaling/scaling.service.ts | 3 +- packages/cli/src/scaling/worker-server.ts | 3 +- .../risk-reporters/instance-risk-reporter.ts | 3 +- .../src/services/active-workflows.service.ts | 2 +- .../services/community-packages.service.ts | 3 +- .../services/credentials-tester.service.ts | 9 +++- packages/cli/src/services/frontend.service.ts | 3 +- packages/cli/src/services/import.service.ts | 2 +- .../src/services/pruning/pruning.service.ts | 3 +- .../cli/src/services/redis-client.service.ts | 2 +- packages/cli/src/services/user.service.ts | 2 +- .../services/workflow-statistics.service.ts | 2 +- packages/cli/src/shutdown/shutdown.service.ts | 2 +- .../sso/saml/__tests__/saml-validator.test.ts | 3 +- .../saml/__tests__/saml.service.ee.test.ts | 2 +- packages/cli/src/sso/saml/saml-validator.ts | 3 +- packages/cli/src/sso/saml/saml.service.ee.ts | 2 +- .../subworkflow-policy-checker.service.ts | 2 +- packages/cli/src/telemetry/index.ts | 3 +- .../src/user-management/email/node-mailer.ts | 4 +- .../email/user-management-mailer.ts | 2 +- packages/cli/src/wait-tracker.ts | 3 +- packages/cli/src/webhooks/live-webhooks.ts | 2 +- packages/cli/src/webhooks/waiting-webhooks.ts | 2 +- packages/cli/src/webhooks/webhook-helpers.ts | 3 +- packages/cli/src/webhooks/webhook.service.ts | 3 +- .../src/workflow-execute-additional-data.ts | 3 +- packages/cli/src/workflow-runner.ts | 3 +- .../workflows/workflow-execution.service.ts | 3 +- .../workflow-history.service.ee.ts | 2 +- .../workflows/workflow-static-data.service.ts | 3 +- .../cli/src/workflows/workflow.service.ee.ts | 2 +- .../cli/src/workflows/workflow.service.ts | 3 +- .../cli/src/workflows/workflows.controller.ts | 2 +- .../active-workflow-manager.test.ts | 2 +- .../test/integration/pruning.service.test.ts | 2 +- .../test/integration/shared/db/workflows.ts | 1 + .../integration/shared/utils/test-server.ts | 2 +- packages/cli/test/shared/mocking.ts | 3 +- packages/core/package.json | 3 ++ packages/core/src/ActiveWorkflows.ts | 9 ++-- packages/core/src/Constants.ts | 4 ++ packages/core/src/DirectoryLoader.ts | 20 ++++---- packages/core/src/InstanceSettings.ts | 36 +++++++------- packages/core/src/InstanceSettingsConfig.ts | 16 +++++++ packages/core/src/NodeExecuteFunctions.ts | 20 ++++---- .../src/ObjectStore/ObjectStore.service.ee.ts | 6 ++- packages/core/src/SerializedBuffer.ts | 2 +- .../src/__tests__/ActiveWorkflows.test.ts | 7 ++- packages/core/src/error-reporter.ts | 7 +-- packages/core/src/index.ts | 1 + .../src/logging/__tests__/logger.test.ts} | 23 ++++----- .../src/logging/logger.ts} | 30 ++++++++---- .../node-execution-context.ts | 5 +- packages/core/test/InstanceSettings.test.ts | 17 +++++-- .../core/test/ObjectStore.service.test.ts | 3 +- packages/core/test/error-reporter.test.ts | 3 +- packages/core/tsconfig.json | 1 + packages/nodes-base/nodes/Ldap/Helpers.ts | 6 +-- packages/nodes-base/nodes/Ldap/Ldap.node.ts | 9 ++-- packages/workflow/package.json | 3 +- packages/workflow/src/Interfaces.ts | 15 +++++- pnpm-lock.yaml | 48 ++++++++++++------- pnpm-workspace.yaml | 2 + 142 files changed, 328 insertions(+), 302 deletions(-) delete mode 100644 packages/cli/src/logging/constants.ts delete mode 100644 packages/cli/src/logging/types.ts rename packages/{cli/src/logging/__tests__/logger.service.test.ts => core/src/logging/__tests__/logger.test.ts} (93%) rename packages/{cli/src/logging/logger.service.ts => core/src/logging/logger.ts} (89%) diff --git a/packages/@n8n/task-runner/src/start.ts b/packages/@n8n/task-runner/src/start.ts index 391b6ba156c66..93ff7422501b3 100644 --- a/packages/@n8n/task-runner/src/start.ts +++ b/packages/@n8n/task-runner/src/start.ts @@ -56,7 +56,7 @@ void (async function start() { if (config.sentryConfig.sentryDsn) { const { ErrorReporter } = await import('n8n-core'); - errorReporter = new ErrorReporter(); + errorReporter = Container.get(ErrorReporter); await errorReporter.init('task_runner', config.sentryConfig.sentryDsn); } diff --git a/packages/cli/package.json b/packages/cli/package.json index 8e9ff0f7ca483..e005ce30255f8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -104,7 +104,6 @@ "bcryptjs": "2.4.3", "bull": "4.12.1", "cache-manager": "5.2.3", - "callsites": "3.1.0", "change-case": "4.1.2", "class-transformer": "0.5.1", "class-validator": "0.14.0", @@ -149,7 +148,7 @@ "p-cancelable": "2.1.1", "p-lazy": "3.1.0", "pg": "8.12.0", - "picocolors": "1.0.1", + "picocolors": "catalog:", "pkce-challenge": "3.0.0", "posthog-node": "3.2.1", "prom-client": "13.2.0", @@ -169,7 +168,6 @@ "typedi": "catalog:", "uuid": "catalog:", "validator": "13.7.0", - "winston": "3.14.2", "ws": "8.17.1", "xml2js": "catalog:", "xmllint-wasm": "3.0.1", diff --git a/packages/cli/src/abstract-server.ts b/packages/cli/src/abstract-server.ts index f4a8a5b2ccd8d..aadd41fb051f5 100644 --- a/packages/cli/src/abstract-server.ts +++ b/packages/cli/src/abstract-server.ts @@ -5,6 +5,7 @@ import { engine as expressHandlebars } from 'express-handlebars'; import { readFile } from 'fs/promises'; import type { Server } from 'http'; import isbot from 'isbot'; +import { Logger } from 'n8n-core'; import { Container, Service } from 'typedi'; import config from '@/config'; @@ -12,7 +13,6 @@ import { N8N_VERSION, TEMPLATES_DIR, inDevelopment, inTest } from '@/constants'; import * as Db from '@/db'; import { OnShutdown } from '@/decorators/on-shutdown'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares'; import { send, sendErrorResponse } from '@/response-helper'; import { LiveWebhooks } from '@/webhooks/live-webhooks'; diff --git a/packages/cli/src/active-executions.ts b/packages/cli/src/active-executions.ts index bc18eade16f9c..a3fdcf6fee644 100644 --- a/packages/cli/src/active-executions.ts +++ b/packages/cli/src/active-executions.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { IDeferredPromise, IExecuteResponsePromiseData, @@ -18,7 +19,6 @@ import type { IExecutionDb, IExecutionsCurrentSummary, } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowIdValid } from '@/utils'; import { ConcurrencyControlService } from './concurrency/concurrency-control.service'; diff --git a/packages/cli/src/active-workflow-manager.ts b/packages/cli/src/active-workflow-manager.ts index 6ef3753af74be..368e2987c80aa 100644 --- a/packages/cli/src/active-workflow-manager.ts +++ b/packages/cli/src/active-workflow-manager.ts @@ -3,6 +3,7 @@ import { ActiveWorkflows, ErrorReporter, InstanceSettings, + Logger, PollContext, TriggerContext, } from 'n8n-core'; @@ -42,7 +43,6 @@ import { OnShutdown } from '@/decorators/on-shutdown'; import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; import type { IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { ActiveWorkflowsService } from '@/services/active-workflows.service'; diff --git a/packages/cli/src/auth/auth.service.ts b/packages/cli/src/auth/auth.service.ts index 492e22ab53331..3a2e4fb0cb127 100644 --- a/packages/cli/src/auth/auth.service.ts +++ b/packages/cli/src/auth/auth.service.ts @@ -2,6 +2,7 @@ import { GlobalConfig } from '@n8n/config'; import { createHash } from 'crypto'; import type { NextFunction, Response } from 'express'; import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken'; +import { Logger } from 'n8n-core'; import Container, { Service } from 'typedi'; import config from '@/config'; @@ -12,7 +13,6 @@ import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import type { AuthenticatedRequest } from '@/requests'; import { JwtService } from '@/services/jwt.service'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index 286fec1de6bec..a10c386f4222f 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -4,6 +4,7 @@ import { Command, Errors } from '@oclif/core'; import { BinaryDataService, InstanceSettings, + Logger, ObjectStoreService, DataDeduplicationService, ErrorReporter, @@ -25,7 +26,6 @@ import { ExternalHooks } from '@/external-hooks'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { PostHogClient } from '@/posthog'; import { ShutdownService } from '@/shutdown/shutdown.service'; diff --git a/packages/cli/src/commands/db/__tests__/revert.test.ts b/packages/cli/src/commands/db/__tests__/revert.test.ts index ce3911b2b617e..8fdabafbec462 100644 --- a/packages/cli/src/commands/db/__tests__/revert.test.ts +++ b/packages/cli/src/commands/db/__tests__/revert.test.ts @@ -1,10 +1,10 @@ import type { Migration, MigrationExecutor } from '@n8n/typeorm'; import { type DataSource } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import { main } from '@/commands/db/revert'; import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; -import { Logger } from '@/logging/logger.service'; import { mockInstance } from '@test/mocking'; const logger = mockInstance(Logger); diff --git a/packages/cli/src/commands/db/revert.ts b/packages/cli/src/commands/db/revert.ts index 45100444059d0..bc9e0f6b3f467 100644 --- a/packages/cli/src/commands/db/revert.ts +++ b/packages/cli/src/commands/db/revert.ts @@ -3,12 +3,12 @@ import type { DataSourceOptions as ConnectionOptions } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { MigrationExecutor, DataSource as Connection } from '@n8n/typeorm'; import { Command, Flags } from '@oclif/core'; +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import { getConnectionOptions } from '@/databases/config'; import type { Migration } from '@/databases/types'; import { wrapMigration } from '@/databases/utils/migration-helpers'; -import { Logger } from '@/logging/logger.service'; // This function is extracted to make it easier to unit test it. // Mocking turned into a mess due to this command using typeorm and the db diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index 64c5a34dae680..ac413077d2f36 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -7,7 +7,6 @@ import { WorkerMissingEncryptionKey } from '@/errors/worker-missing-encryption-k import { EventMessageGeneric } from '@/eventbus/event-message-classes/event-message-generic'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { LogStreamingEventRelay } from '@/events/relays/log-streaming.event-relay'; -import { Logger } from '@/logging/logger.service'; import { PubSubHandler } from '@/scaling/pubsub/pubsub-handler'; import { Subscriber } from '@/scaling/pubsub/subscriber.service'; import type { ScalingService } from '@/scaling/scaling.service'; @@ -67,7 +66,7 @@ export class Worker extends BaseCommand { super(argv, cmdConfig); - this.logger = Container.get(Logger).scoped('scaling'); + this.logger = this.logger.scoped('scaling'); } async init() { diff --git a/packages/cli/src/concurrency/concurrency-control.service.ts b/packages/cli/src/concurrency/concurrency-control.service.ts index 3896daad2e28f..ede6cf899748b 100644 --- a/packages/cli/src/concurrency/concurrency-control.service.ts +++ b/packages/cli/src/concurrency/concurrency-control.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error'; import { EventService } from '@/events/event.service'; import type { IExecutingWorkflowData } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { Telemetry } from '@/telemetry'; import { ConcurrencyQueue } from './concurrency-queue'; diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index 63497600fe300..1ba49a1ef4ce1 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -3,7 +3,9 @@ import convict from 'convict'; import { flatten } from 'flat'; import { readFileSync } from 'fs'; import merge from 'lodash/merge'; +import { Logger } from 'n8n-core'; import { ApplicationError, setGlobalState } from 'n8n-workflow'; +import assert from 'node:assert'; import colors from 'picocolors'; import { Container } from 'typedi'; @@ -31,13 +33,15 @@ const config = convict(schema, { args: [] }); // eslint-disable-next-line @typescript-eslint/unbound-method config.getEnv = config.get; +const logger = Container.get(Logger); +const globalConfig = Container.get(GlobalConfig); + // Load overwrites when not in tests if (!inE2ETests && !inTest) { // Overwrite default configuration with settings which got defined in // optional configuration files const { N8N_CONFIG_FILES } = process.env; if (N8N_CONFIG_FILES !== undefined) { - const globalConfig = Container.get(GlobalConfig); const configFiles = N8N_CONFIG_FILES.split(','); for (const configFile of configFiles) { if (!configFile) continue; @@ -58,9 +62,10 @@ if (!inE2ETests && !inTest) { } } } - console.debug('Loaded config overwrites from', configFile); + logger.debug(`Loaded config overwrites from ${configFile}`); } catch (error) { - console.error('Error loading config file', configFile, error); + assert(error instanceof Error); + logger.error(`Error loading config file ${configFile}`, { error }); } } } @@ -96,7 +101,7 @@ config.validate({ const userManagement = config.get('userManagement'); if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHours) { if (!inTest) - console.warn( + logger.warn( 'N8N_USER_MANAGEMENT_JWT_REFRESH_TIMEOUT_HOURS needs to smaller than N8N_USER_MANAGEMENT_JWT_DURATION_HOURS. Setting N8N_USER_MANAGEMENT_JWT_REFRESH_TIMEOUT_HOURS to 0 for now.', ); @@ -105,16 +110,16 @@ if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHo const executionProcess = config.getEnv('executions.process'); if (executionProcess) { - console.error( - colors.yellow('Please unset the deprecated env variable'), - colors.bold(colors.yellow('EXECUTIONS_PROCESS')), + logger.error( + colors.yellow('Please unset the deprecated env variable') + + colors.bold(colors.yellow('EXECUTIONS_PROCESS')), ); } if (executionProcess === 'own') { - console.error( + logger.error( colors.bold(colors.red('Application failed to start because "Own" mode has been removed.')), ); - console.error( + logger.error( colors.red( 'If you need the isolation and performance gains, please consider using queue mode instead.\n\n', ), @@ -123,7 +128,7 @@ if (executionProcess === 'own') { } setGlobalState({ - defaultTimezone: Container.get(GlobalConfig).generic.timezone, + defaultTimezone: globalConfig.generic.timezone, }); // eslint-disable-next-line import/no-default-export diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index 46ee73a562c1a..faf24ed669bdd 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import validator from 'validator'; @@ -14,7 +15,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { EventService } from '@/events/event.service'; import type { PublicUser } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { PostHogClient } from '@/posthog'; import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests'; diff --git a/packages/cli/src/controllers/e2e.controller.ts b/packages/cli/src/controllers/e2e.controller.ts index a61342320dd04..9d0404d3126d2 100644 --- a/packages/cli/src/controllers/e2e.controller.ts +++ b/packages/cli/src/controllers/e2e.controller.ts @@ -1,5 +1,6 @@ import type { PushMessage } from '@n8n/api-types'; import { Request } from 'express'; +import { Logger } from 'n8n-core'; import Container from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -14,7 +15,6 @@ import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus' import type { BooleanLicenseFeature, NumericLicenseFeature } from '@/interfaces'; import type { FeatureReturnType } from '@/license'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { Push } from '@/push'; import type { UserSetupPayload } from '@/requests'; diff --git a/packages/cli/src/controllers/invitation.controller.ts b/packages/cli/src/controllers/invitation.controller.ts index cbd2afb9f432c..24cff10c643f5 100644 --- a/packages/cli/src/controllers/invitation.controller.ts +++ b/packages/cli/src/controllers/invitation.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -12,7 +13,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { UserRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index a7fb7235fddd5..f56d62aebd559 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -5,6 +5,7 @@ import { } from '@n8n/api-types'; import { plainToInstance } from 'class-transformer'; import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { AuthService } from '@/auth/auth.service'; import type { User } from '@/databases/entities/user'; @@ -16,7 +17,6 @@ import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { AuthenticatedRequest, MeRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts index 2d76642266c51..c7990ddbfdc6a 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts @@ -2,6 +2,7 @@ import Csrf from 'csrf'; import type { Response } from 'express'; import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; +import { Logger } from 'n8n-core'; import nock from 'nock'; import Container from 'typedi'; @@ -16,7 +17,6 @@ import { VariablesService } from '@/environments/variables/variables.service.ee' import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import type { OAuthRequest } from '@/requests'; import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts index b2bd987fb0836..ca9e4db5c6b42 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts @@ -2,6 +2,7 @@ import Csrf from 'csrf'; import { type Response } from 'express'; import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; +import { Logger } from 'n8n-core'; import nock from 'nock'; import Container from 'typedi'; @@ -16,7 +17,6 @@ import { VariablesService } from '@/environments/variables/variables.service.ee' import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import type { OAuthRequest } from '@/requests'; import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts index 3f5c20dfc3c8c..97fb7be24af28 100644 --- a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts +++ b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import Csrf from 'csrf'; import type { Response } from 'express'; -import { Credentials } from 'n8n-core'; +import { Credentials, Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; import { jsonParse, ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -16,7 +16,6 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { AuthenticatedRequest, OAuthRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/controllers/owner.controller.ts b/packages/cli/src/controllers/owner.controller.ts index 47d50ad3f042d..1db250c488a40 100644 --- a/packages/cli/src/controllers/owner.controller.ts +++ b/packages/cli/src/controllers/owner.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -9,7 +10,6 @@ import { GlobalScope, Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; import { validateEntity } from '@/generic-helpers'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { OwnerRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index 2179ff3d9e737..cb5e2c6f8b72f 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -13,7 +14,6 @@ import { UnprocessableRequestError } from '@/errors/response-errors/unprocessabl import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { PasswordResetRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index 8e19be894d438..4cfa18a1e3396 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -1,5 +1,6 @@ import { RoleChangeRequestDto, SettingsUpdateRequestDto } from '@n8n/api-types'; import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { AuthService } from '@/auth/auth.service'; import { CredentialsService } from '@/credentials/credentials.service'; @@ -18,7 +19,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import type { PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import { AuthenticatedRequest, ListQuery, UserRequest } from '@/requests'; import { ProjectService } from '@/services/project.service'; diff --git a/packages/cli/src/controllers/workflow-statistics.controller.ts b/packages/cli/src/controllers/workflow-statistics.controller.ts index 58c99727db1df..b14afc9179c1e 100644 --- a/packages/cli/src/controllers/workflow-statistics.controller.ts +++ b/packages/cli/src/controllers/workflow-statistics.controller.ts @@ -1,4 +1,5 @@ import { Response, NextFunction } from 'express'; +import { Logger } from 'n8n-core'; import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; @@ -7,7 +8,6 @@ import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow- import { Get, Middleware, RestController } from '@/decorators'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IWorkflowStatisticsDataLoaded } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { StatisticsRequest } from './workflow-statistics.types'; diff --git a/packages/cli/src/crash-journal.ts b/packages/cli/src/crash-journal.ts index 577a2f34fe9d0..8afae1e88c96a 100644 --- a/packages/cli/src/crash-journal.ts +++ b/packages/cli/src/crash-journal.ts @@ -1,12 +1,11 @@ import { existsSync } from 'fs'; import { mkdir, utimes, open, rm } from 'fs/promises'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import { join, dirname } from 'path'; import { Container } from 'typedi'; import { inProduction } from '@/constants'; -import { Logger } from '@/logging/logger.service'; export const touchFile = async (filePath: string): Promise => { await mkdir(dirname(filePath), { recursive: true }); diff --git a/packages/cli/src/credentials-overwrites.ts b/packages/cli/src/credentials-overwrites.ts index ed1b492dc68ea..30f6bedfb8ba0 100644 --- a/packages/cli/src/credentials-overwrites.ts +++ b/packages/cli/src/credentials-overwrites.ts @@ -1,11 +1,11 @@ import { GlobalConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import { deepCopy, jsonParse } from 'n8n-workflow'; import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; @Service() export class CredentialsOverwrites { diff --git a/packages/cli/src/credentials/credentials.controller.ts b/packages/cli/src/credentials/credentials.controller.ts index 76db501cf7959..3868c3b87f3a3 100644 --- a/packages/cli/src/credentials/credentials.controller.ts +++ b/packages/cli/src/credentials/credentials.controller.ts @@ -1,6 +1,7 @@ import { GlobalConfig } from '@n8n/config'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { Logger } from 'n8n-core'; import { deepCopy } from 'n8n-workflow'; import { z } from 'zod'; @@ -23,7 +24,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import { CredentialRequest } from '@/requests'; import { NamingService } from '@/services/naming.service'; diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index f9bbf89e57cdb..8261b1364974f 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -6,7 +6,7 @@ import { type FindOptionsRelations, type FindOptionsWhere, } from '@n8n/typeorm'; -import { Credentials } from 'n8n-core'; +import { Credentials, Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject, ICredentialsDecrypted, @@ -33,7 +33,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { userHasScopes } from '@/permissions/check-access'; import type { CredentialRequest, ListQuery } from '@/requests'; import { CredentialsTester } from '@/services/credentials-tester.service'; diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index fbcb7de445463..617dde913681a 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -21,7 +21,7 @@ import { import { DateUtils } from '@n8n/typeorm/util/DateUtils'; import { parse, stringify } from 'flatted'; import pick from 'lodash/pick'; -import { BinaryDataService, ErrorReporter } from 'n8n-core'; +import { BinaryDataService, ErrorReporter, Logger } from 'n8n-core'; import { ExecutionCancelledError, ApplicationError } from 'n8n-workflow'; import type { AnnotationVote, @@ -42,7 +42,6 @@ import type { IExecutionFlattedDb, IExecutionResponse, } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { separate } from '@/utils'; import { ExecutionDataRepository } from './execution-data.repository'; diff --git a/packages/cli/src/databases/subscribers/user-subscriber.ts b/packages/cli/src/databases/subscribers/user-subscriber.ts index 1c55572b14e01..2dc6a1d8e24dd 100644 --- a/packages/cli/src/databases/subscribers/user-subscriber.ts +++ b/packages/cli/src/databases/subscribers/user-subscriber.ts @@ -1,11 +1,9 @@ import type { EntitySubscriberInterface, UpdateEvent } from '@n8n/typeorm'; import { EventSubscriber } from '@n8n/typeorm'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { Container } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import { Project } from '../entities/project'; import { User } from '../entities/user'; import { UserRepository } from '../repositories/user.repository'; diff --git a/packages/cli/src/databases/types.ts b/packages/cli/src/databases/types.ts index 2bb1802bf248b..dce7d9d24361e 100644 --- a/packages/cli/src/databases/types.ts +++ b/packages/cli/src/databases/types.ts @@ -1,8 +1,7 @@ import type { QueryRunner, ObjectLiteral } from '@n8n/typeorm'; +import type { Logger } from 'n8n-core'; import type { INodeTypes } from 'n8n-workflow'; -import type { Logger } from '@/logging/logger.service'; - import type { createSchemaBuilder } from './dsl'; export type DatabaseType = 'mariadb' | 'postgresdb' | 'mysqldb' | 'sqlite'; diff --git a/packages/cli/src/databases/utils/migration-helpers.ts b/packages/cli/src/databases/utils/migration-helpers.ts index 1093096f430be..70839b9337873 100644 --- a/packages/cli/src/databases/utils/migration-helpers.ts +++ b/packages/cli/src/databases/utils/migration-helpers.ts @@ -2,14 +2,13 @@ import { GlobalConfig } from '@n8n/config'; import type { ObjectLiteral } from '@n8n/typeorm'; import type { QueryRunner } from '@n8n/typeorm/query-runner/QueryRunner'; import { readFileSync, rmSync } from 'fs'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import { Container } from 'typedi'; import { inTest } from '@/constants'; import { createSchemaBuilder } from '@/databases/dsl'; import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@/databases/types'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json'; diff --git a/packages/cli/src/deprecation/deprecation.service.ts b/packages/cli/src/deprecation/deprecation.service.ts index fef25ff0dd9cb..b3c4cb7d21173 100644 --- a/packages/cli/src/deprecation/deprecation.service.ts +++ b/packages/cli/src/deprecation/deprecation.service.ts @@ -1,8 +1,7 @@ +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - type EnvVarName = string; type Deprecation = { diff --git a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts b/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts index e1ebf0e56aade..1599f7b4bde3a 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts +++ b/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts @@ -1,12 +1,13 @@ import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; +import { Container } from 'typedi'; import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; describe('SourceControlService', () => { const preferencesService = new SourceControlPreferencesService( - new InstanceSettings(mock()), + Container.get(InstanceSettings), mock(), mock(), ); diff --git a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts index 03352410f435f..cb678d534d41c 100644 --- a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts @@ -1,5 +1,5 @@ import { rmSync } from 'fs'; -import { Credentials, InstanceSettings } from 'n8n-core'; +import { Credentials, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type ICredentialDataDecryptedObject } from 'n8n-workflow'; import { writeFile as fsWriteFile, rm as fsRm } from 'node:fs/promises'; import path from 'path'; @@ -11,7 +11,6 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl import { TagRepository } from '@/databases/repositories/tag.repository'; import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_CREDENTIAL_EXPORT_FOLDER, diff --git a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts index 99571cdd528d0..0d87d4c2d18c5 100644 --- a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts @@ -1,4 +1,5 @@ import { execSync } from 'child_process'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import path from 'path'; import type { @@ -14,7 +15,6 @@ import type { import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { OwnershipService } from '@/services/ownership.service'; import { diff --git a/packages/cli/src/environments/source-control/source-control-helper.ee.ts b/packages/cli/src/environments/source-control/source-control-helper.ee.ts index 00a9875741eda..6e8b92f09b444 100644 --- a/packages/cli/src/environments/source-control/source-control-helper.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-helper.ee.ts @@ -1,12 +1,12 @@ import { generateKeyPairSync } from 'crypto'; import { constants as fsConstants, mkdirSync, accessSync } from 'fs'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { ok } from 'node:assert/strict'; import path from 'path'; import { Container } from 'typedi'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { isContainedWithin } from '@/utils/path-util'; import { diff --git a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts index 2e7da80c13312..10ae293b601da 100644 --- a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; import glob from 'fast-glob'; -import { Credentials, ErrorReporter, InstanceSettings } from 'n8n-core'; +import { Credentials, ErrorReporter, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse, ensureError } from 'n8n-workflow'; import { readFile as fsReadFile } from 'node:fs/promises'; import path from 'path'; @@ -23,7 +23,6 @@ import { VariablesRepository } from '@/databases/repositories/variables.reposito import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { IWorkflowToImport } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { isUniqueConstraintError } from '@/response-helper'; import { assertNever } from '@/utils'; diff --git a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts index 7c061b6c3c5be..ec46e024549aa 100644 --- a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts @@ -1,7 +1,7 @@ import type { ValidationError } from 'class-validator'; import { validate } from 'class-validator'; import { rm as fsRm } from 'fs/promises'; -import { Cipher, InstanceSettings } from 'n8n-core'; +import { Cipher, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import { writeFile, chmod, readFile } from 'node:fs/promises'; import path from 'path'; @@ -9,7 +9,6 @@ import Container, { Service } from 'typedi'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_SSH_FOLDER, diff --git a/packages/cli/src/environments/source-control/source-control.service.ee.ts b/packages/cli/src/environments/source-control/source-control.service.ee.ts index e010210262f62..8fcb1f35711fa 100644 --- a/packages/cli/src/environments/source-control/source-control.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control.service.ee.ts @@ -1,4 +1,5 @@ import { writeFileSync } from 'fs'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import path from 'path'; import type { PushResult } from 'simple-git'; @@ -10,7 +11,6 @@ import type { Variables } from '@/databases/entities/variables'; import { TagRepository } from '@/databases/repositories/tag.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_DEFAULT_EMAIL, diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts index 4046855f30e0a..90049da1fff6a 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts @@ -1,8 +1,8 @@ +import { Logger } from 'n8n-core'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { Container } from 'typedi'; import type { EventDestinations } from '@/databases/entities/event-destinations'; -import { Logger } from '@/logging/logger.service'; import { MessageEventBusDestinationSentry } from './message-event-bus-destination-sentry.ee'; import { MessageEventBusDestinationSyslog } from './message-event-bus-destination-syslog.ee'; diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts index 83db469d7913c..c0e7657e0fa95 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import { Logger } from 'n8n-core'; import type { MessageEventBusDestinationOptions, MessageEventBusDestinationSyslogOptions, @@ -7,8 +8,6 @@ import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import syslog from 'syslog-client'; import Container from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts index 7b65767b04ea7..c3aaf71173513 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { INodeCredentials, MessageEventBusDestinationOptions } from 'n8n-workflow'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { Container } from 'typedi'; @@ -5,7 +6,6 @@ import { v4 as uuid } from 'uuid'; import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import type { EventMessageTypes } from '../event-message-classes'; import type { AbstractEventMessage } from '../event-message-classes/abstract-event-message'; diff --git a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts index 3f3cb50b185dd..c418035a70a2b 100644 --- a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts +++ b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts @@ -4,7 +4,7 @@ import { GlobalConfig } from '@n8n/config'; import { once as eventOnce } from 'events'; import { createReadStream, existsSync, rmSync } from 'fs'; import remove from 'lodash/remove'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { EventMessageTypeNames, jsonParse } from 'n8n-workflow'; import path, { parse } from 'path'; import readline from 'readline'; @@ -12,7 +12,6 @@ import Container from 'typedi'; import { Worker } from 'worker_threads'; import { inTest } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import type { EventMessageTypes } from '../event-message-classes'; import { isEventMessageOptions } from '../event-message-classes/abstract-event-message'; diff --git a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts index 3cf5a5a5d0572..2cd35a596f811 100644 --- a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts +++ b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts @@ -5,6 +5,7 @@ import type { DeleteResult } from '@n8n/typeorm'; import { In } from '@n8n/typeorm'; import EventEmitter from 'events'; import uniqby from 'lodash/uniqBy'; +import { Logger } from 'n8n-core'; import type { MessageEventBusDestinationOptions } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -13,7 +14,6 @@ import { EventDestinationsRepository } from '@/databases/repositories/event-dest import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { ExecutionRecoveryService } from '../../executions/execution-recovery.service'; diff --git a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts index eedbf27c9e6eb..ac52cf3920228 100644 --- a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts +++ b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts @@ -1,11 +1,11 @@ import { ErrorReporter } from 'n8n-core'; +import { Logger } from 'n8n-core'; import type { IRunExecutionData, ITaskData, IWorkflowBase } from 'n8n-workflow'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { saveExecutionProgress } from '@/execution-lifecycle-hooks/save-execution-progress'; import * as fnModule from '@/execution-lifecycle-hooks/to-save-settings'; import type { IExecutionResponse } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { mockInstance } from '@test/mocking'; mockInstance(Logger); diff --git a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts index d9a1a9a0e99c1..15ac8b905cb4c 100644 --- a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts +++ b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts @@ -1,10 +1,9 @@ -import { BinaryDataService } from 'n8n-core'; import type { BinaryData } from 'n8n-core'; +import { BinaryDataService, Logger } from 'n8n-core'; import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; import Container from 'typedi'; import config from '@/config'; -import { Logger } from '@/logging/logger.service'; /** * Whenever the execution ID is not available to the binary data service at the diff --git a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts index c1de2646c0269..2047c9e82eade 100644 --- a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts +++ b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts @@ -1,10 +1,9 @@ -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IRunExecutionData, ITaskData, IWorkflowBase } from 'n8n-workflow'; import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { toSaveSettings } from '@/execution-lifecycle-hooks/to-save-settings'; -import { Logger } from '@/logging/logger.service'; export async function saveExecutionProgress( workflowData: IWorkflowBase, diff --git a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts index 68fd528f14110..4c91222126cae 100644 --- a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts +++ b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts @@ -1,10 +1,10 @@ import pick from 'lodash/pick'; +import { Logger } from 'n8n-core'; import { ensureError, type ExecutionStatus, type IRun, type IWorkflowBase } from 'n8n-workflow'; import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import type { IExecutionDb, UpdateExecutionPayload } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { ExecutionMetadataService } from '@/services/execution-metadata.service'; import { isWorkflowIdValid } from '@/utils'; diff --git a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts index 115a1a52f60e8..0e6017a2bd395 100644 --- a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts +++ b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts @@ -22,7 +22,7 @@ import { setupMessages } from './utils'; describe('ExecutionRecoveryService', () => { const push = mockInstance(Push); - const instanceSettings = new InstanceSettings(mock()); + const instanceSettings = Container.get(InstanceSettings); let executionRecoveryService: ExecutionRecoveryService; let executionRepository: ExecutionRepository; diff --git a/packages/cli/src/executions/execution-recovery.service.ts b/packages/cli/src/executions/execution-recovery.service.ts index a10fc995a472d..f307ce0677f5c 100644 --- a/packages/cli/src/executions/execution-recovery.service.ts +++ b/packages/cli/src/executions/execution-recovery.service.ts @@ -1,5 +1,5 @@ import type { DateTime } from 'luxon'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import type { IRun, ITaskData } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -10,7 +10,6 @@ import { NodeCrashedError } from '@/errors/node-crashed.error'; import { WorkflowCrashedError } from '@/errors/workflow-crashed.error'; import { EventService } from '@/events/event.service'; import type { IExecutionResponse } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { Push } from '@/push'; import { getWorkflowHooksMain } from '@/workflow-execute-additional-data'; // @TODO: Dependency cycle diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index 433955254f698..ffddb271649fa 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -1,5 +1,6 @@ import { GlobalConfig } from '@n8n/config'; import { validate as jsonSchemaValidate } from 'jsonschema'; +import { Logger } from 'n8n-core'; import type { ExecutionError, ExecutionStatus, @@ -38,7 +39,6 @@ import type { IWorkflowDb, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { WaitTracker } from '@/wait-tracker'; import { WorkflowRunner } from '@/workflow-runner'; diff --git a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts index 2de681a7d62be..d4adf17255554 100644 --- a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts @@ -1,4 +1,4 @@ -import { Cipher } from 'n8n-core'; +import { Cipher, Logger } from 'n8n-core'; import { jsonParse, type IDataObject, ApplicationError, ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -10,7 +10,6 @@ import type { SecretsProviderSettings, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { EXTERNAL_SECRETS_INITIAL_BACKOFF, EXTERNAL_SECRETS_MAX_BACKOFF } from './constants'; diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts index 6c2c0669fb79a..629b3ad626bc2 100644 --- a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts @@ -1,10 +1,10 @@ +import { Logger } from 'n8n-core'; import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { UnknownAuthTypeError } from '@/errors/unknown-auth-type.error'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { AwsSecretsClient } from './aws-secrets-client'; import type { AwsSecretsManagerContext } from './types'; diff --git a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts index 7961f21bad24b..01995d699012b 100644 --- a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts +++ b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts @@ -1,11 +1,11 @@ import type { SecretClient } from '@azure/keyvault-secrets'; +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { AzureKeyVaultContext } from './types'; diff --git a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts index c4bf71cb72169..ec29a281984c0 100644 --- a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts @@ -1,10 +1,10 @@ import type { SecretManagerServiceClient as GcpClient } from '@google-cloud/secret-manager'; +import { Logger } from 'n8n-core'; import { ensureError, jsonParse, type INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { GcpSecretsManagerContext, diff --git a/packages/cli/src/external-secrets/providers/vault.ts b/packages/cli/src/external-secrets/providers/vault.ts index 0f1e93a5da5cf..8030832376fe9 100644 --- a/packages/cli/src/external-secrets/providers/vault.ts +++ b/packages/cli/src/external-secrets/providers/vault.ts @@ -1,11 +1,11 @@ import type { AxiosInstance, AxiosResponse } from 'axios'; import axios from 'axios'; +import { Logger } from 'n8n-core'; import type { IDataObject, INodeProperties } from 'n8n-workflow'; import { Container } from 'typedi'; import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; import { SecretsProvider } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '../constants'; import { preferGet } from '../external-secrets-helper.ee'; diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index 8581483577402..168b9c907933e 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -1,6 +1,6 @@ import { Help } from '@oclif/core'; -import Container from 'typedi'; -import { Logger } from 'winston'; +import { Logger } from 'n8n-core'; +import { Container } from 'typedi'; // oclif expects a default export // eslint-disable-next-line import/no-default-export diff --git a/packages/cli/src/ldap/ldap.service.ee.ts b/packages/cli/src/ldap/ldap.service.ee.ts index b552db697401a..1445f56f13c35 100644 --- a/packages/cli/src/ldap/ldap.service.ee.ts +++ b/packages/cli/src/ldap/ldap.service.ee.ts @@ -2,7 +2,7 @@ import { QueryFailedError } from '@n8n/typeorm'; import type { Entry as LdapUser, ClientOptions } from 'ldapts'; import { Client } from 'ldapts'; -import { Cipher } from 'n8n-core'; +import { Cipher, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import type { ConnectionOptions } from 'tls'; import { Service } from 'typedi'; @@ -14,7 +14,6 @@ import { SettingsRepository } from '@/databases/repositories/settings.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { getCurrentAuthenticationMethod, isEmailCurrentAuthenticationMethod, diff --git a/packages/cli/src/license.ts b/packages/cli/src/license.ts index 2a3ae6fd6dee6..59804b6a7d0c4 100644 --- a/packages/cli/src/license.ts +++ b/packages/cli/src/license.ts @@ -1,13 +1,12 @@ import { GlobalConfig } from '@n8n/config'; import type { TEntitlement, TFeatures, TLicenseBlock } from '@n8n_io/license-sdk'; import { LicenseManager } from '@n8n_io/license-sdk'; -import { InstanceSettings, ObjectStoreService } from 'n8n-core'; +import { InstanceSettings, ObjectStoreService, Logger } from 'n8n-core'; import Container, { Service } from 'typedi'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { LicenseMetricsService } from '@/metrics/license-metrics.service'; import { diff --git a/packages/cli/src/license/license.service.ts b/packages/cli/src/license/license.service.ts index 1419d58b83572..750b42b432381 100644 --- a/packages/cli/src/license/license.service.ts +++ b/packages/cli/src/license/license.service.ts @@ -1,4 +1,5 @@ import axios, { AxiosError } from 'axios'; +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; type LicenseError = Error & { errorId?: keyof typeof LicenseErrors }; diff --git a/packages/cli/src/load-nodes-and-credentials.ts b/packages/cli/src/load-nodes-and-credentials.ts index db62e8415ea71..e462bd4157861 100644 --- a/packages/cli/src/load-nodes-and-credentials.ts +++ b/packages/cli/src/load-nodes-and-credentials.ts @@ -11,6 +11,7 @@ import { LazyPackageDirectoryLoader, UnrecognizedCredentialTypeError, UnrecognizedNodeTypeError, + Logger, } from 'n8n-core'; import type { KnownNodesAndCredentials, @@ -36,7 +37,6 @@ import { CLI_DIR, inE2ETests, } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { isContainedWithin } from '@/utils/path-util'; interface LoadedNodesAndCredentials { diff --git a/packages/cli/src/logging/constants.ts b/packages/cli/src/logging/constants.ts deleted file mode 100644 index 107327694b1b9..0000000000000 --- a/packages/cli/src/logging/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const noOp = () => {}; - -export const LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'silent'] as const; diff --git a/packages/cli/src/logging/types.ts b/packages/cli/src/logging/types.ts deleted file mode 100644 index bb01834326090..0000000000000 --- a/packages/cli/src/logging/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { LogScope } from '@n8n/config'; - -import type { LOG_LEVELS } from './constants'; - -export type LogLevel = (typeof LOG_LEVELS)[number]; - -export type LogMetadata = { - [key: string]: unknown; - scopes?: LogScope[]; - file?: string; - function?: string; -}; - -export type LogLocationMetadata = Pick; diff --git a/packages/cli/src/manual-execution.service.ts b/packages/cli/src/manual-execution.service.ts index 65174d20b50f8..c6749696feb6b 100644 --- a/packages/cli/src/manual-execution.service.ts +++ b/packages/cli/src/manual-execution.service.ts @@ -4,6 +4,7 @@ import { filterDisabledNodes, recreateNodeExecutionStack, WorkflowExecute, + Logger, } from 'n8n-core'; import type { IPinData, @@ -16,8 +17,6 @@ import type { import type PCancelable from 'p-cancelable'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - @Service() export class ManualExecutionService { constructor(private readonly logger: Logger) {} diff --git a/packages/cli/src/push/__tests__/websocket.push.test.ts b/packages/cli/src/push/__tests__/websocket.push.test.ts index fd1e2f27a0b52..c13a319ebf27a 100644 --- a/packages/cli/src/push/__tests__/websocket.push.test.ts +++ b/packages/cli/src/push/__tests__/websocket.push.test.ts @@ -1,10 +1,10 @@ import type { PushMessage } from '@n8n/api-types'; import { EventEmitter } from 'events'; +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import type WebSocket from 'ws'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { WebSocketPush } from '@/push/websocket.push'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/push/abstract.push.ts b/packages/cli/src/push/abstract.push.ts index 574f8a0def056..b1c4514d8d6f6 100644 --- a/packages/cli/src/push/abstract.push.ts +++ b/packages/cli/src/push/abstract.push.ts @@ -1,10 +1,9 @@ import type { PushMessage } from '@n8n/api-types'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { assert, jsonStringify } from 'n8n-workflow'; import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import type { OnPushMessage } from '@/push/types'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/response-helper.ts b/packages/cli/src/response-helper.ts index 0e70aa312f72c..f7f448cc9dc6f 100644 --- a/packages/cli/src/response-helper.ts +++ b/packages/cli/src/response-helper.ts @@ -1,13 +1,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import type { Request, Response } from 'express'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { FORM_TRIGGER_PATH_IDENTIFIER, NodeApiError } from 'n8n-workflow'; import { Readable } from 'node:stream'; import picocolors from 'picocolors'; import Container from 'typedi'; import { inDevelopment } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { ResponseError } from './errors/response-errors/abstract/response.error'; diff --git a/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts b/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts index 61cfb8b8e85cf..31abac807a2bf 100644 --- a/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts +++ b/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts @@ -1,7 +1,7 @@ import { TaskRunnersConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; +import type { Logger } from 'n8n-core'; -import type { Logger } from '@/logging/logger.service'; import type { TaskRunnerAuthService } from '@/runners/auth/task-runner-auth.service'; import { TaskRunnerRestartLoopError } from '@/runners/errors/task-runner-restart-loop-error'; import { RunnerLifecycleEvents } from '@/runners/runner-lifecycle-events'; diff --git a/packages/cli/src/runners/__tests__/task-runner-process.test.ts b/packages/cli/src/runners/__tests__/task-runner-process.test.ts index 85dbaa6930884..42d6794287231 100644 --- a/packages/cli/src/runners/__tests__/task-runner-process.test.ts +++ b/packages/cli/src/runners/__tests__/task-runner-process.test.ts @@ -1,8 +1,8 @@ import { TaskRunnersConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import type { ChildProcess, SpawnOptions } from 'node:child_process'; -import { Logger } from '@/logging/logger.service'; import type { TaskRunnerAuthService } from '@/runners/auth/task-runner-auth.service'; import { TaskRunnerProcess } from '@/runners/task-runner-process'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/runners/runner-ws-server.ts b/packages/cli/src/runners/runner-ws-server.ts index 8ea3a7edbe547..53b8f18cf8f71 100644 --- a/packages/cli/src/runners/runner-ws-server.ts +++ b/packages/cli/src/runners/runner-ws-server.ts @@ -1,11 +1,11 @@ import { TaskRunnersConfig } from '@n8n/config'; import type { BrokerMessage, RunnerMessage } from '@n8n/task-runner'; +import { Logger } from 'n8n-core'; import { ApplicationError, jsonStringify } from 'n8n-workflow'; import { Service } from 'typedi'; import type WebSocket from 'ws'; import { Time, WsStatusCodes } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { DefaultTaskRunnerDisconnectAnalyzer } from './default-task-runner-disconnect-analyzer'; import { RunnerLifecycleEvents } from './runner-lifecycle-events'; diff --git a/packages/cli/src/runners/task-broker.service.ts b/packages/cli/src/runners/task-broker.service.ts index e52992d38eed8..ebbed80860b50 100644 --- a/packages/cli/src/runners/task-broker.service.ts +++ b/packages/cli/src/runners/task-broker.service.ts @@ -5,13 +5,13 @@ import type { RunnerMessage, TaskResultData, } from '@n8n/task-runner'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { nanoid } from 'nanoid'; import { Service } from 'typedi'; import config from '@/config'; import { Time } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { TaskDeferredError, TaskRejectError } from './errors'; import { TaskRunnerTimeoutError } from './errors/task-runner-timeout.error'; diff --git a/packages/cli/src/runners/task-runner-module.ts b/packages/cli/src/runners/task-runner-module.ts index 434daa066a35c..97f3f4e481c71 100644 --- a/packages/cli/src/runners/task-runner-module.ts +++ b/packages/cli/src/runners/task-runner-module.ts @@ -1,11 +1,10 @@ import { TaskRunnersConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import * as a from 'node:assert/strict'; import Container, { Service } from 'typedi'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import type { TaskRunnerRestartLoopError } from '@/runners/errors/task-runner-restart-loop-error'; import type { TaskRunnerProcess } from '@/runners/task-runner-process'; import { TaskRunnerProcessRestartLoopDetector } from '@/runners/task-runner-process-restart-loop-detector'; diff --git a/packages/cli/src/runners/task-runner-process.ts b/packages/cli/src/runners/task-runner-process.ts index 2716383f17430..668792994212e 100644 --- a/packages/cli/src/runners/task-runner-process.ts +++ b/packages/cli/src/runners/task-runner-process.ts @@ -1,11 +1,11 @@ import { TaskRunnersConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import * as a from 'node:assert/strict'; import { spawn } from 'node:child_process'; import * as process from 'node:process'; import { Service } from 'typedi'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { TaskRunnerAuthService } from './auth/task-runner-auth.service'; import { forwardToLogger } from './forward-to-logger'; diff --git a/packages/cli/src/runners/task-runner-server.ts b/packages/cli/src/runners/task-runner-server.ts index 2b1f481b0e338..bbe1d7cd6adeb 100644 --- a/packages/cli/src/runners/task-runner-server.ts +++ b/packages/cli/src/runners/task-runner-server.ts @@ -1,6 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import compression from 'compression'; import express from 'express'; +import { Logger } from 'n8n-core'; import * as a from 'node:assert/strict'; import { randomBytes } from 'node:crypto'; import { ServerResponse, type Server, createServer as createHttpServer } from 'node:http'; @@ -10,7 +11,6 @@ import { Service } from 'typedi'; import { Server as WSServer } from 'ws'; import { inTest } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { bodyParser, rawBodyReader } from '@/middlewares'; import { send } from '@/response-helper'; import { TaskRunnerAuthController } from '@/runners/auth/task-runner-auth.controller'; diff --git a/packages/cli/src/scaling/job-processor.ts b/packages/cli/src/scaling/job-processor.ts index 51b86c3922301..5e760e40c1063 100644 --- a/packages/cli/src/scaling/job-processor.ts +++ b/packages/cli/src/scaling/job-processor.ts @@ -1,5 +1,5 @@ import type { RunningJobSummary } from '@n8n/api-types'; -import { ErrorReporter, InstanceSettings, WorkflowExecute } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, WorkflowExecute, Logger } from 'n8n-core'; import type { ExecutionStatus, IExecuteResponsePromiseData, IRun } from 'n8n-workflow'; import { BINARY_ENCODING, ApplicationError, Workflow } from 'n8n-workflow'; import type PCancelable from 'p-cancelable'; @@ -8,7 +8,6 @@ import { Service } from 'typedi'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/scaling/multi-main-setup.ee.ts b/packages/cli/src/scaling/multi-main-setup.ee.ts index dab9f17cc6dc9..1a2554965c24e 100644 --- a/packages/cli/src/scaling/multi-main-setup.ee.ts +++ b/packages/cli/src/scaling/multi-main-setup.ee.ts @@ -1,10 +1,9 @@ import { GlobalConfig } from '@n8n/config'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { Service } from 'typedi'; import config from '@/config'; import { Time } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { RedisClientService } from '@/services/redis-client.service'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/scaling/pubsub/publisher.service.ts b/packages/cli/src/scaling/pubsub/publisher.service.ts index 4723b1d37dea7..551d1b6caf02f 100644 --- a/packages/cli/src/scaling/pubsub/publisher.service.ts +++ b/packages/cli/src/scaling/pubsub/publisher.service.ts @@ -1,10 +1,9 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'ioredis'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; +import type { LogMetadata } from 'n8n-workflow'; import { Service } from 'typedi'; import config from '@/config'; -import { Logger } from '@/logging/logger.service'; -import type { LogMetadata } from '@/logging/types'; import { RedisClientService } from '@/services/redis-client.service'; import type { PubSub } from './pubsub.types'; diff --git a/packages/cli/src/scaling/pubsub/subscriber.service.ts b/packages/cli/src/scaling/pubsub/subscriber.service.ts index 0ce343c139b0a..c2d5498243006 100644 --- a/packages/cli/src/scaling/pubsub/subscriber.service.ts +++ b/packages/cli/src/scaling/pubsub/subscriber.service.ts @@ -1,13 +1,12 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'ioredis'; import debounce from 'lodash/debounce'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { jsonParse } from 'n8n-workflow'; +import type { LogMetadata } from 'n8n-workflow'; import { Service } from 'typedi'; import config from '@/config'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; -import type { LogMetadata } from '@/logging/types'; import { RedisClientService } from '@/services/redis-client.service'; import type { PubSub } from './pubsub.types'; diff --git a/packages/cli/src/scaling/scaling.service.ts b/packages/cli/src/scaling/scaling.service.ts index ebc8e4499ca90..5896e2976be42 100644 --- a/packages/cli/src/scaling/scaling.service.ts +++ b/packages/cli/src/scaling/scaling.service.ts @@ -1,5 +1,5 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter, InstanceSettings } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, BINARY_ENCODING, sleep, jsonStringify, ensureError } from 'n8n-workflow'; import type { IExecuteResponsePromiseData } from 'n8n-workflow'; import { strict } from 'node:assert'; @@ -12,7 +12,6 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito import { OnShutdown } from '@/decorators/on-shutdown'; import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { assertNever } from '@/utils'; diff --git a/packages/cli/src/scaling/worker-server.ts b/packages/cli/src/scaling/worker-server.ts index ee622d789cbb9..8112f3a4f5bdb 100644 --- a/packages/cli/src/scaling/worker-server.ts +++ b/packages/cli/src/scaling/worker-server.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import type { Application } from 'express'; import express from 'express'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { strict as assert } from 'node:assert'; import http from 'node:http'; import type { Server } from 'node:http'; @@ -13,7 +13,6 @@ import { CredentialsOverwritesAlreadySetError } from '@/errors/credentials-overw import { NonJsonBodyError } from '@/errors/non-json-body.error'; import { ExternalHooks } from '@/external-hooks'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service'; import { rawBodyReader, bodyParser } from '@/middlewares'; import * as ResponseHelper from '@/response-helper'; diff --git a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts index 37113e4c40489..92874e87f05e1 100644 --- a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts @@ -1,12 +1,11 @@ import { GlobalConfig } from '@n8n/config'; import axios from 'axios'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { Service } from 'typedi'; import config from '@/config'; import { getN8nPackageJson, inDevelopment } from '@/constants'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { Logger } from '@/logging/logger.service'; import { isApiEnabled } from '@/public-api'; import { ENV_VARS_DOCS_URL, diff --git a/packages/cli/src/services/active-workflows.service.ts b/packages/cli/src/services/active-workflows.service.ts index 61aa875d1a61a..d2c50c74c2144 100644 --- a/packages/cli/src/services/active-workflows.service.ts +++ b/packages/cli/src/services/active-workflows.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { Service } from 'typedi'; import { ActivationErrorsService } from '@/activation-errors.service'; @@ -5,7 +6,6 @@ import type { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { Logger } from '@/logging/logger.service'; @Service() export class ActiveWorkflowsService { diff --git a/packages/cli/src/services/community-packages.service.ts b/packages/cli/src/services/community-packages.service.ts index 9f09d0c310def..a94b4d5c4f784 100644 --- a/packages/cli/src/services/community-packages.service.ts +++ b/packages/cli/src/services/community-packages.service.ts @@ -2,8 +2,8 @@ import { GlobalConfig } from '@n8n/config'; import axios from 'axios'; import { exec } from 'child_process'; import { access as fsAccess, mkdir as fsMkdir } from 'fs/promises'; -import { InstanceSettings } from 'n8n-core'; import type { PackageDirectoryLoader } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type PublicInstalledPackage } from 'n8n-workflow'; import { Service } from 'typedi'; import { promisify } from 'util'; @@ -22,7 +22,6 @@ import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import type { CommunityPackages } from '@/interfaces'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { toError } from '@/utils'; diff --git a/packages/cli/src/services/credentials-tester.service.ts b/packages/cli/src/services/credentials-tester.service.ts index 6ae7201ac0558..0709d77e06bb5 100644 --- a/packages/cli/src/services/credentials-tester.service.ts +++ b/packages/cli/src/services/credentials-tester.service.ts @@ -4,7 +4,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-call */ import get from 'lodash/get'; -import { ErrorReporter, NodeExecuteFunctions, RoutingNode, isObjectLiteral } from 'n8n-core'; +import { + ErrorReporter, + Logger, + NodeExecuteFunctions, + RoutingNode, + isObjectLiteral, +} from 'n8n-core'; import type { ICredentialsDecrypted, ICredentialTestFunction, @@ -28,7 +34,6 @@ import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index 1645e98304d56..75fe36358faf3 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -3,7 +3,7 @@ import { GlobalConfig, FrontendConfig, SecurityConfig } from '@n8n/config'; import { createWriteStream } from 'fs'; import { mkdir } from 'fs/promises'; import uniq from 'lodash/uniq'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import type { ICredentialType, INodeTypeBaseDescription } from 'n8n-workflow'; import path from 'path'; import { Container, Service } from 'typedi'; @@ -16,7 +16,6 @@ import { getVariablesLimit } from '@/environments/variables/environment-helpers' import { getLdapLoginLabel } from '@/ldap/helpers.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { isApiEnabled } from '@/public-api'; import type { CommunityPackagesService } from '@/services/community-packages.service'; import { getSamlLoginLabel } from '@/sso/saml/saml-helpers'; diff --git a/packages/cli/src/services/import.service.ts b/packages/cli/src/services/import.service.ts index 2402863bab645..4f63357dd67a9 100644 --- a/packages/cli/src/services/import.service.ts +++ b/packages/cli/src/services/import.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { type INode, type INodeCredentialsDetails } from 'n8n-workflow'; import { Service } from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -11,7 +12,6 @@ import { CredentialsRepository } from '@/databases/repositories/credentials.repo import { TagRepository } from '@/databases/repositories/tag.repository'; import * as Db from '@/db'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { replaceInvalidCredentials } from '@/workflow-helpers'; @Service() diff --git a/packages/cli/src/services/pruning/pruning.service.ts b/packages/cli/src/services/pruning/pruning.service.ts index aad8c5490f340..15d81dc48ec0b 100644 --- a/packages/cli/src/services/pruning/pruning.service.ts +++ b/packages/cli/src/services/pruning/pruning.service.ts @@ -1,5 +1,5 @@ import { ExecutionsConfig } from '@n8n/config'; -import { BinaryDataService, InstanceSettings } from 'n8n-core'; +import { BinaryDataService, InstanceSettings, Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { strict } from 'node:assert'; import { Service } from 'typedi'; @@ -8,7 +8,6 @@ import { Time } from '@/constants'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { connectionState as dbConnectionState } from '@/db'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '../orchestration.service'; diff --git a/packages/cli/src/services/redis-client.service.ts b/packages/cli/src/services/redis-client.service.ts index c58453016509f..894d3af67102d 100644 --- a/packages/cli/src/services/redis-client.service.ts +++ b/packages/cli/src/services/redis-client.service.ts @@ -1,10 +1,10 @@ import { GlobalConfig } from '@n8n/config'; import ioRedis from 'ioredis'; import type { Cluster, RedisOptions } from 'ioredis'; +import { Logger } from 'n8n-core'; import { Service } from 'typedi'; import { Debounce } from '@/decorators/debounce'; -import { Logger } from '@/logging/logger.service'; import { TypedEmitter } from '@/typed-emitter'; import type { RedisClientType } from '../scaling/redis/redis.types'; diff --git a/packages/cli/src/services/user.service.ts b/packages/cli/src/services/user.service.ts index e47dd026b0769..3d2cb304719cb 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { IUserSettings } from 'n8n-workflow'; import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { UserRepository } from '@/databases/repositories/user.repository'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; import type { Invitation, PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { PostHogClient } from '@/posthog'; import type { UserRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/services/workflow-statistics.service.ts b/packages/cli/src/services/workflow-statistics.service.ts index 53cbac50947f8..9c0282eb850b0 100644 --- a/packages/cli/src/services/workflow-statistics.service.ts +++ b/packages/cli/src/services/workflow-statistics.service.ts @@ -1,10 +1,10 @@ +import { Logger } from 'n8n-core'; import type { INode, IRun, IWorkflowBase } from 'n8n-workflow'; import { Service } from 'typedi'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { UserService } from '@/services/user.service'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/shutdown/shutdown.service.ts b/packages/cli/src/shutdown/shutdown.service.ts index 8ff8570757b86..1597b2a27f43c 100644 --- a/packages/cli/src/shutdown/shutdown.service.ts +++ b/packages/cli/src/shutdown/shutdown.service.ts @@ -1,9 +1,9 @@ import { type Class, ErrorReporter } from 'n8n-core'; +import { Logger } from 'n8n-core'; import { ApplicationError, assert } from 'n8n-workflow'; import { Container, Service } from 'typedi'; import { LOWEST_SHUTDOWN_PRIORITY, HIGHEST_SHUTDOWN_PRIORITY } from '@/constants'; -import { Logger } from '@/logging/logger.service'; type HandlerFn = () => Promise | void; export type ServiceClass = Class>; diff --git a/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts b/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts index 8594676ab2999..563c7934ea251 100644 --- a/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts @@ -1,4 +1,5 @@ -import { Logger } from '@/logging/logger.service'; +import { Logger } from 'n8n-core'; + import { mockInstance } from '@test/mocking'; import { validateMetadata, validateResponse } from '../saml-validator'; diff --git a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts index 8bd5e32da20a5..708592e8e7c97 100644 --- a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts @@ -1,9 +1,9 @@ import type express from 'express'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import * as samlHelpers from '@/sso/saml/saml-helpers'; import { SamlService } from '@/sso/saml/saml.service.ee'; diff --git a/packages/cli/src/sso/saml/saml-validator.ts b/packages/cli/src/sso/saml/saml-validator.ts index 07e9853f90044..582fe624a5d88 100644 --- a/packages/cli/src/sso/saml/saml-validator.ts +++ b/packages/cli/src/sso/saml/saml-validator.ts @@ -1,8 +1,7 @@ +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import type { XMLFileInfo } from 'xmllint-wasm'; -import { Logger } from '@/logging/logger.service'; - let xmlMetadata: XMLFileInfo; let xmlProtocol: XMLFileInfo; diff --git a/packages/cli/src/sso/saml/saml.service.ee.ts b/packages/cli/src/sso/saml/saml.service.ee.ts index 3672c8fe6ff23..2944d9adf1e4d 100644 --- a/packages/cli/src/sso/saml/saml.service.ee.ts +++ b/packages/cli/src/sso/saml/saml.service.ee.ts @@ -1,6 +1,7 @@ import axios from 'axios'; import type express from 'express'; import https from 'https'; +import { Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; import type { BindingContext, PostBindingContext } from 'samlify/types/src/entity'; @@ -12,7 +13,6 @@ import { SettingsRepository } from '@/databases/repositories/settings.repository import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import { SAML_PREFERENCES_DB_KEY } from './constants'; diff --git a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts index 6c64fc0b3a23f..0415977e2e10f 100644 --- a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts +++ b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts @@ -1,10 +1,10 @@ import { GlobalConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import { type Workflow, type INode, type WorkflowSettings } from 'n8n-workflow'; import { Service } from 'typedi'; import type { Project } from '@/databases/entities/project'; import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error'; -import { Logger } from '@/logging/logger.service'; import { AccessService } from '@/services/access.service'; import { OwnershipService } from '@/services/ownership.service'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index a8d39d898ee8a..e8099e32cbf36 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import type RudderStack from '@rudderstack/rudder-sdk-node'; import axios from 'axios'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import type { ITelemetryTrackProperties } from 'n8n-workflow'; import { Container, Service } from 'typedi'; @@ -13,7 +13,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { OnShutdown } from '@/decorators/on-shutdown'; import type { IExecutionTrackProperties } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; diff --git a/packages/cli/src/user-management/email/node-mailer.ts b/packages/cli/src/user-management/email/node-mailer.ts index a35ab77318456..4f4dc4f8953a8 100644 --- a/packages/cli/src/user-management/email/node-mailer.ts +++ b/packages/cli/src/user-management/email/node-mailer.ts @@ -1,14 +1,12 @@ import { GlobalConfig } from '@n8n/config'; import { pick } from 'lodash'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import path from 'node:path'; import type { Transporter } from 'nodemailer'; import { createTransport } from 'nodemailer'; import type SMTPConnection from 'nodemailer/lib/smtp-connection'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import type { MailData, SendEmailResult } from './interfaces'; @Service() diff --git a/packages/cli/src/user-management/email/user-management-mailer.ts b/packages/cli/src/user-management/email/user-management-mailer.ts index 3acddad185589..25794cec8d6dc 100644 --- a/packages/cli/src/user-management/email/user-management-mailer.ts +++ b/packages/cli/src/user-management/email/user-management-mailer.ts @@ -2,6 +2,7 @@ import { GlobalConfig } from '@n8n/config'; import { existsSync } from 'fs'; import { readFile } from 'fs/promises'; import Handlebars from 'handlebars'; +import { Logger } from 'n8n-core'; import { join as pathJoin } from 'path'; import { Container, Service } from 'typedi'; @@ -11,7 +12,6 @@ import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { UserRepository } from '@/databases/repositories/user.repository'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import { toError } from '@/utils'; diff --git a/packages/cli/src/wait-tracker.ts b/packages/cli/src/wait-tracker.ts index f42905ace1978..02480110ae9f2 100644 --- a/packages/cli/src/wait-tracker.ts +++ b/packages/cli/src/wait-tracker.ts @@ -1,10 +1,9 @@ -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type IWorkflowExecutionDataProcess } from 'n8n-workflow'; import { Service } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { OwnershipService } from '@/services/ownership.service'; import { WorkflowRunner } from '@/workflow-runner'; diff --git a/packages/cli/src/webhooks/live-webhooks.ts b/packages/cli/src/webhooks/live-webhooks.ts index 6d6fc9161de2c..1ebfef347033d 100644 --- a/packages/cli/src/webhooks/live-webhooks.ts +++ b/packages/cli/src/webhooks/live-webhooks.ts @@ -1,4 +1,5 @@ import type { Response } from 'express'; +import { Logger } from 'n8n-core'; import { Workflow, CHAT_TRIGGER_NODE_TYPE } from 'n8n-workflow'; import type { INode, IWebhookData, IHttpRequestMethods } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -6,7 +7,6 @@ import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import { WebhookService } from '@/webhooks/webhook.service'; diff --git a/packages/cli/src/webhooks/waiting-webhooks.ts b/packages/cli/src/webhooks/waiting-webhooks.ts index 63557091893b0..ed2f8404bcaac 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -1,4 +1,5 @@ import type express from 'express'; +import { Logger } from 'n8n-core'; import { FORM_NODE_TYPE, type INodes, @@ -13,7 +14,6 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IExecutionResponse, IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/webhooks/webhook-helpers.ts b/packages/cli/src/webhooks/webhook-helpers.ts index 665708988171c..51b81fad8371d 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -9,7 +9,7 @@ import { GlobalConfig } from '@n8n/config'; import type express from 'express'; import get from 'lodash/get'; -import { BinaryDataService, ErrorReporter } from 'n8n-core'; +import { BinaryDataService, ErrorReporter, Logger } from 'n8n-core'; import type { IBinaryData, IBinaryKeyData, @@ -46,7 +46,6 @@ import { InternalServerError } from '@/errors/response-errors/internal-server.er import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; import type { IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { parseBody } from '@/middlewares'; import { OwnershipService } from '@/services/ownership.service'; import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; diff --git a/packages/cli/src/webhooks/webhook.service.ts b/packages/cli/src/webhooks/webhook.service.ts index 80b12b04cd897..f571c9450bedc 100644 --- a/packages/cli/src/webhooks/webhook.service.ts +++ b/packages/cli/src/webhooks/webhook.service.ts @@ -1,4 +1,4 @@ -import { HookContext, WebhookContext } from 'n8n-core'; +import { HookContext, WebhookContext, Logger } from 'n8n-core'; import { ApplicationError, Node, NodeHelpers } from 'n8n-workflow'; import type { IHttpRequestMethods, @@ -16,7 +16,6 @@ import { Service } from 'typedi'; import type { WebhookEntity } from '@/databases/entities/webhook-entity'; import { WebhookRepository } from '@/databases/repositories/webhook.repository'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { CacheService } from '@/services/cache/cache.service'; diff --git a/packages/cli/src/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index 29c8d67502f80..bf97ce0a3fba7 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -5,7 +5,7 @@ import type { PushMessage, PushType } from '@n8n/api-types'; import { GlobalConfig } from '@n8n/config'; import { stringify } from 'flatted'; -import { ErrorReporter, WorkflowExecute, isObjectLiteral } from 'n8n-core'; +import { ErrorReporter, Logger, WorkflowExecute, isObjectLiteral } from 'n8n-core'; import { ApplicationError, NodeOperationError, Workflow, WorkflowHooks } from 'n8n-workflow'; import type { IDataObject, @@ -58,7 +58,6 @@ import { updateExistingExecution, } from './execution-lifecycle-hooks/shared/shared-hook-functions'; import { toSaveSettings } from './execution-lifecycle-hooks/to-save-settings'; -import { Logger } from './logging/logger.service'; import { TaskManager } from './runners/task-managers/task-manager'; import { SecretsHelper } from './secrets-helpers'; import { OwnershipService } from './services/ownership.service'; diff --git a/packages/cli/src/workflow-runner.ts b/packages/cli/src/workflow-runner.ts index 973d512e62079..30cd50d6f0fd8 100644 --- a/packages/cli/src/workflow-runner.ts +++ b/packages/cli/src/workflow-runner.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-shadow */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { ErrorReporter, InstanceSettings, WorkflowExecute } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, Logger, WorkflowExecute } from 'n8n-core'; import type { ExecutionError, IDeferredPromise, @@ -21,7 +21,6 @@ import { ActiveExecutions } from '@/active-executions'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import type { ScalingService } from '@/scaling/scaling.service'; import type { Job, JobData } from '@/scaling/scaling.types'; diff --git a/packages/cli/src/workflows/workflow-execution.service.ts b/packages/cli/src/workflows/workflow-execution.service.ts index 27b673c245f66..842ddfe72661b 100644 --- a/packages/cli/src/workflows/workflow-execution.service.ts +++ b/packages/cli/src/workflows/workflow-execution.service.ts @@ -1,5 +1,5 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IDeferredPromise, IExecuteData, @@ -20,7 +20,6 @@ import type { User } from '@/databases/entities/user'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { CreateExecutionPayload, IWorkflowDb, IWorkflowErrorData } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { SubworkflowPolicyChecker } from '@/subworkflows/subworkflow-policy-checker.service'; import { TestWebhooks } from '@/webhooks/test-webhooks'; diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts index 3b171e34227c4..2e23a7d64a3e0 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -8,7 +9,6 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { SharedWorkflowNotFoundError } from '@/errors/shared-workflow-not-found.error'; import { WorkflowHistoryVersionNotFoundError } from '@/errors/workflow-history-version-not-found.error'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowHistoryEnabled } from './workflow-history-helper.ee'; diff --git a/packages/cli/src/workflows/workflow-static-data.service.ts b/packages/cli/src/workflows/workflow-static-data.service.ts index 3e5159dc9a438..aaff18f319262 100644 --- a/packages/cli/src/workflows/workflow-static-data.service.ts +++ b/packages/cli/src/workflows/workflow-static-data.service.ts @@ -1,10 +1,9 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IDataObject, Workflow } from 'n8n-workflow'; import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowIdValid } from '@/utils'; @Service() diff --git a/packages/cli/src/workflows/workflow.service.ee.ts b/packages/cli/src/workflows/workflow.service.ee.ts index 90a8af90b1678..debaf85073c43 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In, type EntityManager } from '@n8n/typeorm'; import omit from 'lodash/omit'; +import { Logger } from 'n8n-core'; import { ApplicationError, NodeOperationError, WorkflowActivationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -17,7 +18,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflow.error'; -import { Logger } from '@/logging/logger.service'; import { OwnershipService } from '@/services/ownership.service'; import { ProjectService } from '@/services/project.service'; diff --git a/packages/cli/src/workflows/workflow.service.ts b/packages/cli/src/workflows/workflow.service.ts index 7220e1a640cad..facd372656d9e 100644 --- a/packages/cli/src/workflows/workflow.service.ts +++ b/packages/cli/src/workflows/workflow.service.ts @@ -5,7 +5,7 @@ import type { EntityManager } from '@n8n/typeorm'; import { In } from '@n8n/typeorm'; import omit from 'lodash/omit'; import pick from 'lodash/pick'; -import { BinaryDataService } from 'n8n-core'; +import { BinaryDataService, Logger } from 'n8n-core'; import { NodeApiError } from 'n8n-workflow'; import { Service } from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -24,7 +24,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; -import { Logger } from '@/logging/logger.service'; import { hasSharing, type ListQuery } from '@/requests'; import { OrchestrationService } from '@/services/orchestration.service'; import { OwnershipService } from '@/services/ownership.service'; diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index 24765b422a2c1..f097b3cab61f9 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -3,6 +3,7 @@ import { GlobalConfig } from '@n8n/config'; import { In, type FindOptionsRelations } from '@n8n/typeorm'; import axios from 'axios'; import express from 'express'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { v4 as uuid } from 'uuid'; import { z } from 'zod'; @@ -27,7 +28,6 @@ import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { IWorkflowResponse } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import * as ResponseHelper from '@/response-helper'; import { NamingService } from '@/services/naming.service'; diff --git a/packages/cli/test/integration/active-workflow-manager.test.ts b/packages/cli/test/integration/active-workflow-manager.test.ts index a3e4f657f26ed..f724d156a8277 100644 --- a/packages/cli/test/integration/active-workflow-manager.test.ts +++ b/packages/cli/test/integration/active-workflow-manager.test.ts @@ -1,4 +1,5 @@ import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import { NodeApiError, Workflow } from 'n8n-workflow'; import type { IWebhookData, WorkflowActivateMode } from 'n8n-workflow'; import { Container } from 'typedi'; @@ -9,7 +10,6 @@ import type { WebhookEntity } from '@/databases/entities/webhook-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; import { SecretsHelper } from '@/secrets-helpers'; diff --git a/packages/cli/test/integration/pruning.service.test.ts b/packages/cli/test/integration/pruning.service.test.ts index 4f34048a1a465..9d4103e84e802 100644 --- a/packages/cli/test/integration/pruning.service.test.ts +++ b/packages/cli/test/integration/pruning.service.test.ts @@ -21,7 +21,7 @@ import { mockInstance, mockLogger } from '../shared/mocking'; describe('softDeleteOnPruningCycle()', () => { let pruningService: PruningService; - const instanceSettings = new InstanceSettings(mock()); + const instanceSettings = Container.get(InstanceSettings); instanceSettings.markAsLeader(); const now = new Date(); diff --git a/packages/cli/test/integration/shared/db/workflows.ts b/packages/cli/test/integration/shared/db/workflows.ts index 5c86f1dc3534b..bc8099e494fed 100644 --- a/packages/cli/test/integration/shared/db/workflows.ts +++ b/packages/cli/test/integration/shared/db/workflows.ts @@ -40,6 +40,7 @@ export function newWorkflow(attributes: Partial = {}): WorkflowE ], connections: connections ?? {}, versionId: versionId ?? uuid(), + settings: {}, ...attributes, }); diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index ef0588b8d731c..f99e0938546ff 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -1,5 +1,6 @@ import cookieParser from 'cookie-parser'; import express from 'express'; +import { Logger } from 'n8n-core'; import type superagent from 'superagent'; import request from 'supertest'; import { Container } from 'typedi'; @@ -11,7 +12,6 @@ import { AUTH_COOKIE_NAME } from '@/constants'; import type { User } from '@/databases/entities/user'; import { ControllerRegistry } from '@/decorators'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser } from '@/middlewares'; import { PostHogClient } from '@/posthog'; import { Push } from '@/push'; diff --git a/packages/cli/test/shared/mocking.ts b/packages/cli/test/shared/mocking.ts index 129acb585c62a..535388c55626b 100644 --- a/packages/cli/test/shared/mocking.ts +++ b/packages/cli/test/shared/mocking.ts @@ -1,11 +1,10 @@ import { DataSource, EntityManager, type EntityMetadata } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; import type { Class } from 'n8n-core'; +import type { Logger } from 'n8n-core'; import type { DeepPartial } from 'ts-essentials'; import { Container } from 'typedi'; -import type { Logger } from '@/logging/logger.service'; - export const mockInstance = ( serviceClass: Class, data: DeepPartial | undefined = undefined, diff --git a/packages/core/package.json b/packages/core/package.json index 26b41800d9c75..401a9f81c749f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -42,6 +42,7 @@ "@sentry/node": "catalog:", "aws4": "1.11.0", "axios": "catalog:", + "callsites": "catalog:", "chardet": "2.0.0", "concat-stream": "2.0.0", "cron": "3.1.7", @@ -56,11 +57,13 @@ "nanoid": "catalog:", "oauth-1.0a": "2.2.6", "p-cancelable": "2.1.1", + "picocolors": "catalog:", "pretty-bytes": "5.6.0", "qs": "6.11.0", "ssh2": "1.15.0", "typedi": "catalog:", "uuid": "catalog:", + "winston": "3.14.2", "xml2js": "catalog:", "zod": "catalog:" } diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts index e3ca8614c2fa8..173f73baca939 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -11,7 +11,6 @@ import type { } from 'n8n-workflow'; import { ApplicationError, - LoggerProxy as Logger, toCronExpression, TriggerCloseError, WorkflowActivationError, @@ -21,12 +20,14 @@ import { Service } from 'typedi'; import { ErrorReporter } from './error-reporter'; import type { IWorkflowData } from './Interfaces'; +import { Logger } from './logging/logger'; import { ScheduledTaskManager } from './ScheduledTaskManager'; import { TriggersAndPollers } from './TriggersAndPollers'; @Service() export class ActiveWorkflows { constructor( + private readonly logger: Logger, private readonly scheduledTaskManager: ScheduledTaskManager, private readonly triggersAndPollers: TriggersAndPollers, private readonly errorReporter: ErrorReporter, @@ -151,7 +152,7 @@ export class ActiveWorkflows { const cronTimes = (pollTimes.item || []).map(toCronExpression); // The trigger function to execute when the cron-time got reached const executeTrigger = async (testingTrigger = false) => { - Logger.debug(`Polling trigger initiated for workflow "${workflow.name}"`, { + this.logger.debug(`Polling trigger initiated for workflow "${workflow.name}"`, { workflowName: workflow.name, workflowId: workflow.id, }); @@ -193,7 +194,7 @@ export class ActiveWorkflows { */ async remove(workflowId: string) { if (!this.isActive(workflowId)) { - Logger.warn(`Cannot deactivate already inactive workflow ID "${workflowId}"`); + this.logger.warn(`Cannot deactivate already inactive workflow ID "${workflowId}"`); return false; } @@ -222,7 +223,7 @@ export class ActiveWorkflows { await response.closeFunction(); } catch (e) { if (e instanceof TriggerCloseError) { - Logger.error( + this.logger.error( `There was a problem calling "closeFunction" on "${e.node.name}" in workflow "${workflowId}"`, ); this.errorReporter.error(e, { extra: { workflowId } }); diff --git a/packages/core/src/Constants.ts b/packages/core/src/Constants.ts index ceaf77566a0d3..82a39b07cd26d 100644 --- a/packages/core/src/Constants.ts +++ b/packages/core/src/Constants.ts @@ -1,6 +1,10 @@ import type { INodeProperties } from 'n8n-workflow'; import { cronNodeOptions } from 'n8n-workflow'; +const { NODE_ENV } = process.env; +export const inProduction = NODE_ENV === 'production'; +export const inDevelopment = !NODE_ENV || NODE_ENV === 'development'; + export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS'; export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKNOWN__'; export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__'; diff --git a/packages/core/src/DirectoryLoader.ts b/packages/core/src/DirectoryLoader.ts index cd223da2ddf6f..fe9fee87694e4 100644 --- a/packages/core/src/DirectoryLoader.ts +++ b/packages/core/src/DirectoryLoader.ts @@ -15,15 +15,13 @@ import type { IVersionedNodeType, KnownNodesAndCredentials, } from 'n8n-workflow'; -import { - ApplicationError, - LoggerProxy as Logger, - applyDeclarativeNodeOptionParameters, - jsonParse, -} from 'n8n-workflow'; +import { ApplicationError, applyDeclarativeNodeOptionParameters, jsonParse } from 'n8n-workflow'; import { readFileSync } from 'node:fs'; import { readFile } from 'node:fs/promises'; import * as path from 'path'; +import Container from 'typedi'; + +import { Logger } from '@/logging/logger'; import { loadClassInIsolation } from './ClassLoader'; import { commonCORSParameters, commonPollingParameters, CUSTOM_NODES_CATEGORY } from './Constants'; @@ -78,6 +76,8 @@ export abstract class DirectoryLoader { readonly nodesByCredential: Record = {}; + protected readonly logger = Container.get(Logger); + constructor( readonly directory: string, protected readonly excludeNodes: string[] = [], @@ -336,7 +336,7 @@ export abstract class DirectoryLoader { node.description.codex = codex; } catch { - Logger.debug(`No codex available for: ${node.description.name}`); + this.logger.debug(`No codex available for: ${node.description.name}`); if (isCustom) { node.description.codex = { @@ -454,7 +454,7 @@ export class PackageDirectoryLoader extends DirectoryLoader { this.inferSupportedNodes(); - Logger.debug(`Loaded all credentials and nodes from ${this.packageName}`, { + this.logger.debug(`Loaded all credentials and nodes from ${this.packageName}`, { credentials: credentials?.length ?? 0, nodes: nodes?.length ?? 0, }); @@ -550,7 +550,7 @@ export class LazyPackageDirectoryLoader extends PackageDirectoryLoader { ); } - Logger.debug(`Lazy-loading nodes and credentials from ${this.packageJson.name}`, { + this.logger.debug(`Lazy-loading nodes and credentials from ${this.packageJson.name}`, { nodes: this.types.nodes?.length ?? 0, credentials: this.types.credentials?.length ?? 0, }); @@ -559,7 +559,7 @@ export class LazyPackageDirectoryLoader extends PackageDirectoryLoader { return; // We can load nodes and credentials lazily now } catch { - Logger.debug("Can't enable lazy-loading"); + this.logger.debug("Can't enable lazy-loading"); await super.loadAll(); } } diff --git a/packages/core/src/InstanceSettings.ts b/packages/core/src/InstanceSettings.ts index f611e034b337f..814f75ef94835 100644 --- a/packages/core/src/InstanceSettings.ts +++ b/packages/core/src/InstanceSettings.ts @@ -5,6 +5,8 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync import path from 'path'; import { Service } from 'typedi'; +import { Logger } from '@/logging/logger'; + import { Memoized } from './decorators'; import { InstanceSettingsConfig } from './InstanceSettingsConfig'; @@ -28,13 +30,11 @@ const inTest = process.env.NODE_ENV === 'test'; @Service() export class InstanceSettings { - private readonly userHome = this.getUserHome(); - /** The path to the n8n folder in which all n8n related data gets saved */ - readonly n8nFolder = path.join(this.userHome, '.n8n'); + readonly n8nFolder = this.config.n8nFolder; /** The path to the folder where all generated static assets are copied to */ - readonly staticCacheDir = path.join(this.userHome, '.cache/n8n/public'); + readonly staticCacheDir = path.join(this.config.userHome, '.cache/n8n/public'); /** The path to the folder containing custom nodes and credentials */ readonly customExtensionDir = path.join(this.n8nFolder, 'custom'); @@ -58,7 +58,10 @@ export class InstanceSettings { readonly instanceType: InstanceType; - constructor(private readonly config: InstanceSettingsConfig) { + constructor( + private readonly config: InstanceSettingsConfig, + private readonly logger: Logger, + ) { const command = process.argv[2]; this.instanceType = ['webhook', 'worker'].includes(command) ? (command as InstanceType) @@ -154,15 +157,6 @@ export class InstanceSettings { this.save({ ...this.settings, ...newSettings }); } - /** - * The home folder path of the user. - * If none can be found it falls back to the current working directory - */ - private getUserHome() { - const homeVarName = process.platform === 'win32' ? 'USERPROFILE' : 'HOME'; - return process.env.N8N_USER_FOLDER ?? process.env[homeVarName] ?? process.cwd(); - } - /** * Load instance settings from the settings file. If missing, create a new * settings file with an auto-generated encryption key. @@ -198,7 +192,9 @@ export class InstanceSettings { this.save(settings); if (!inTest && !process.env.N8N_ENCRYPTION_KEY) { - console.info(`No encryption key found - Auto-generated and saved to: ${this.settingsFile}`); + this.logger.info( + `No encryption key found - Auto-generated and saved to: ${this.settingsFile}`, + ); } this.ensureSettingsFilePermissions(); @@ -260,11 +256,11 @@ export class InstanceSettings { const permissionsResult = toResult(() => { const stats = statSync(this.settingsFile); - return stats.mode & 0o777; + return stats?.mode & 0o777; }); // If we can't determine the permissions, log a warning and skip the check if (!permissionsResult.ok) { - console.warn( + this.logger.warn( `Could not ensure settings file permissions: ${permissionsResult.error.message}. To skip this check, set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); return; @@ -277,7 +273,7 @@ export class InstanceSettings { // If the permissions are incorrect and the flag is not set, log a warning if (!this.enforceSettingsFilePermissions.isSet) { - console.warn( + this.logger.warn( `Permissions 0${permissionsResult.result.toString(8)} for n8n settings file ${this.settingsFile} are too wide. This is ignored for now, but in the future n8n will attempt to change the permissions automatically. To automatically enforce correct permissions now set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true (recommended), or turn this check off set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); // The default is false so we skip the enforcement for now @@ -285,7 +281,7 @@ export class InstanceSettings { } if (this.enforceSettingsFilePermissions.enforce) { - console.warn( + this.logger.warn( `Permissions 0${permissionsResult.result.toString(8)} for n8n settings file ${this.settingsFile} are too wide. Changing permissions to 0600..`, ); const chmodResult = toResult(() => chmodSync(this.settingsFile, 0o600)); @@ -293,7 +289,7 @@ export class InstanceSettings { // Some filesystems don't support permissions. In this case we log the // error and ignore it. We might want to prevent the app startup in the // future in this case. - console.warn( + this.logger.warn( `Could not enforce settings file permissions: ${chmodResult.error.message}. To skip this check, set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); } diff --git a/packages/core/src/InstanceSettingsConfig.ts b/packages/core/src/InstanceSettingsConfig.ts index 60baf8b80f9cd..dd28472a05050 100644 --- a/packages/core/src/InstanceSettingsConfig.ts +++ b/packages/core/src/InstanceSettingsConfig.ts @@ -1,4 +1,5 @@ import { Config, Env } from '@n8n/config'; +import path from 'node:path'; @Config export class InstanceSettingsConfig { @@ -9,4 +10,19 @@ export class InstanceSettingsConfig { */ @Env('N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS') enforceSettingsFilePermissions: boolean = false; + + /** + * The home folder path of the user. + * If none can be found it falls back to the current working directory + */ + readonly userHome: string; + + readonly n8nFolder: string; + + constructor() { + const homeVarName = process.platform === 'win32' ? 'USERPROFILE' : 'HOME'; + this.userHome = process.env.N8N_USER_FOLDER ?? process.env[homeVarName] ?? process.cwd(); + + this.n8nFolder = path.join(this.userHome, '.n8n'); + } } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 20d5ae0833f04..3a0ebf22f9309 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -76,7 +76,6 @@ import type { SchedulingFunctions, } from 'n8n-workflow'; import { - LoggerProxy as Logger, NodeApiError, NodeHelpers, NodeOperationError, @@ -97,6 +96,8 @@ import { Readable } from 'stream'; import Container from 'typedi'; import url, { URL, URLSearchParams } from 'url'; +import { Logger } from '@/logging/logger'; + import { BinaryDataService } from './BinaryData/BinaryData.service'; import type { BinaryData } from './BinaryData/types'; import { binaryToBuffer } from './BinaryData/utils'; @@ -201,7 +202,7 @@ async function generateContentLengthHeader(config: AxiosRequestConfig) { 'content-length': length, }; } catch (error) { - Logger.error('Unable to calculate form data length', { error }); + Container.get(Logger).error('Unable to calculate form data length', { error }); } } @@ -792,7 +793,7 @@ export async function proxyRequestToAxios( error.config = error.request = undefined; error.options = pick(config ?? {}, ['url', 'method', 'data', 'headers']); if (response) { - Logger.debug('Request proxied to Axios failed', { status: response.status }); + Container.get(Logger).debug('Request proxied to Axios failed', { status: response.status }); let responseData = response.data; if (Buffer.isBuffer(responseData) || responseData instanceof Readable) { @@ -1406,7 +1407,7 @@ export async function requestOAuth2( if (isN8nRequest) { return await this.helpers.httpRequest(newRequestOptions).catch(async (error: AxiosError) => { if (error.response?.status === 401) { - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`, ); const tokenRefreshOptions: IDataObject = {}; @@ -1425,7 +1426,7 @@ export async function requestOAuth2( let newToken; - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); // if it's OAuth2 with client credentials grant type, get a new token @@ -1436,7 +1437,7 @@ export async function requestOAuth2( newToken = await token.refresh(tokenRefreshOptions as unknown as ClientOAuth2Options); } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); @@ -1499,7 +1500,7 @@ export async function requestOAuth2( Authorization: '', }; } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`, ); @@ -1512,7 +1513,7 @@ export async function requestOAuth2( } else { newToken = await token.refresh(tokenRefreshOptions as unknown as ClientOAuth2Options); } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); @@ -1534,7 +1535,7 @@ export async function requestOAuth2( credentials as unknown as ICredentialDataDecryptedObject, ); - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been saved to database successfully.`, ); @@ -2562,6 +2563,7 @@ export function getExecuteTriggerFunctions( export function getCredentialTestFunctions(): ICredentialTestFunctions { return { + logger: Container.get(Logger), helpers: { ...getSSHTunnelFunctions(), request: async (uriOrObject: string | object, options?: object) => { diff --git a/packages/core/src/ObjectStore/ObjectStore.service.ee.ts b/packages/core/src/ObjectStore/ObjectStore.service.ee.ts index 0e4d8463dfccb..6379de7789f88 100644 --- a/packages/core/src/ObjectStore/ObjectStore.service.ee.ts +++ b/packages/core/src/ObjectStore/ObjectStore.service.ee.ts @@ -2,11 +2,13 @@ import { sign } from 'aws4'; import type { Request as Aws4Options, Credentials as Aws4Credentials } from 'aws4'; import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios'; -import { ApplicationError, LoggerProxy as Logger } from 'n8n-workflow'; +import { ApplicationError } from 'n8n-workflow'; import { createHash } from 'node:crypto'; import type { Readable } from 'stream'; import { Service } from 'typedi'; +import { Logger } from '@/logging/logger'; + import type { Bucket, ConfigSchemaCredentials, @@ -30,7 +32,7 @@ export class ObjectStoreService { private isReadOnly = false; - private logger = Logger; + constructor(private readonly logger: Logger) {} async init(host: string, bucket: Bucket, credentials: ConfigSchemaCredentials) { this.host = host; diff --git a/packages/core/src/SerializedBuffer.ts b/packages/core/src/SerializedBuffer.ts index 7a96884729bcf..d6ea874c7a61d 100644 --- a/packages/core/src/SerializedBuffer.ts +++ b/packages/core/src/SerializedBuffer.ts @@ -1,4 +1,4 @@ -import { isObjectLiteral } from './utils'; +import { isObjectLiteral } from '@/utils'; /** A nodejs Buffer gone through JSON.stringify */ export type SerializedBuffer = { diff --git a/packages/core/src/__tests__/ActiveWorkflows.test.ts b/packages/core/src/__tests__/ActiveWorkflows.test.ts index 85487a0cece09..410b4779bae94 100644 --- a/packages/core/src/__tests__/ActiveWorkflows.test.ts +++ b/packages/core/src/__tests__/ActiveWorkflows.test.ts @@ -42,7 +42,12 @@ describe('ActiveWorkflows', () => { beforeEach(() => { jest.clearAllMocks(); - activeWorkflows = new ActiveWorkflows(scheduledTaskManager, triggersAndPollers, errorReporter); + activeWorkflows = new ActiveWorkflows( + mock(), + scheduledTaskManager, + triggersAndPollers, + errorReporter, + ); }); type PollTimes = { item: TriggerTime[] }; diff --git a/packages/core/src/error-reporter.ts b/packages/core/src/error-reporter.ts index b6fc936daaa7a..b52fd6d2f6279 100644 --- a/packages/core/src/error-reporter.ts +++ b/packages/core/src/error-reporter.ts @@ -2,11 +2,12 @@ import type { NodeOptions } from '@sentry/node'; import { close } from '@sentry/node'; import type { ErrorEvent, EventHint } from '@sentry/types'; import { AxiosError } from 'axios'; -import { ApplicationError, LoggerProxy, type ReportingOptions } from 'n8n-workflow'; +import { ApplicationError, type ReportingOptions } from 'n8n-workflow'; import { createHash } from 'node:crypto'; import { Service } from 'typedi'; import type { InstanceType } from './InstanceSettings'; +import { Logger } from './logging/logger'; @Service() export class ErrorReporter { @@ -15,7 +16,7 @@ export class ErrorReporter { private report: (error: Error | string, options?: ReportingOptions) => void; - constructor() { + constructor(private readonly logger: Logger) { // eslint-disable-next-line @typescript-eslint/unbound-method this.report = this.defaultReport; } @@ -30,7 +31,7 @@ export class ErrorReporter { do { const msg = [e.message + context, e.stack ? `\n${e.stack}\n` : ''].join(''); const meta = e instanceof ApplicationError ? e.extra : undefined; - LoggerProxy.error(msg, meta); + this.logger.error(msg, meta); e = e.cause as Error; } while (e); } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index bec9767ffa923..7abbd9ad9aa7f 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -11,6 +11,7 @@ export * from './Credentials'; export * from './DirectoryLoader'; export * from './Interfaces'; export { InstanceSettings, InstanceType } from './InstanceSettings'; +export { Logger } from './logging/logger'; export * from './NodeExecuteFunctions'; export * from './RoutingNode'; export * from './WorkflowExecute'; diff --git a/packages/cli/src/logging/__tests__/logger.service.test.ts b/packages/core/src/logging/__tests__/logger.test.ts similarity index 93% rename from packages/cli/src/logging/__tests__/logger.service.test.ts rename to packages/core/src/logging/__tests__/logger.test.ts index 2ffbf2120eb34..d34eaf250a099 100644 --- a/packages/cli/src/logging/__tests__/logger.service.test.ts +++ b/packages/core/src/logging/__tests__/logger.test.ts @@ -5,10 +5,11 @@ jest.mock('n8n-workflow', () => ({ import type { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; -import type { InstanceSettings } from 'n8n-core'; import { LoggerProxy } from 'n8n-workflow'; -import { Logger } from '@/logging/logger.service'; +import type { InstanceSettingsConfig } from '@/InstanceSettingsConfig'; + +import { Logger } from '../logger'; describe('Logger', () => { beforeEach(() => { @@ -25,13 +26,13 @@ describe('Logger', () => { }); test('if root, should initialize `LoggerProxy` with instance', () => { - const logger = new Logger(globalConfig, mock(), { isRoot: true }); + const logger = new Logger(globalConfig, mock(), { isRoot: true }); expect(LoggerProxy.init).toHaveBeenCalledWith(logger); }); test('if scoped, should not initialize `LoggerProxy`', () => { - new Logger(globalConfig, mock(), { isRoot: false }); + new Logger(globalConfig, mock(), { isRoot: false }); expect(LoggerProxy.init).not.toHaveBeenCalled(); }); @@ -47,7 +48,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const { transports } = logger.getInternalLogger(); @@ -72,7 +73,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock({ n8nFolder: '/tmp' })); + const logger = new Logger(globalConfig, mock({ n8nFolder: '/tmp' })); const { transports } = logger.getInternalLogger(); @@ -94,7 +95,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -113,7 +114,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -132,7 +133,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -151,7 +152,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -170,7 +171,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); diff --git a/packages/cli/src/logging/logger.service.ts b/packages/core/src/logging/logger.ts similarity index 89% rename from packages/cli/src/logging/logger.service.ts rename to packages/core/src/logging/logger.ts index 46441e5a339ca..e959affba3b16 100644 --- a/packages/cli/src/logging/logger.service.ts +++ b/packages/core/src/logging/logger.ts @@ -2,20 +2,26 @@ import type { LogScope } from '@n8n/config'; import { GlobalConfig } from '@n8n/config'; import callsites from 'callsites'; import type { TransformableInfo } from 'logform'; -import { InstanceSettings, isObjectLiteral } from 'n8n-core'; import { LoggerProxy, LOG_LEVELS } from 'n8n-workflow'; +import type { + Logger as LoggerType, + LogLocationMetadata, + LogLevel, + LogMetadata, +} from 'n8n-workflow'; import path, { basename } from 'node:path'; import pc from 'picocolors'; import { Service } from 'typedi'; import winston from 'winston'; -import { inDevelopment, inProduction } from '@/constants'; +import { inDevelopment, inProduction } from '@/Constants'; +import { InstanceSettingsConfig } from '@/InstanceSettingsConfig'; +import { isObjectLiteral } from '@/utils'; -import { noOp } from './constants'; -import type { LogLocationMetadata, LogLevel, LogMetadata } from './types'; +const noOp = () => {}; @Service() -export class Logger { +export class Logger implements LoggerType { private internalLogger: winston.Logger; private readonly level: LogLevel; @@ -28,7 +34,7 @@ export class Logger { constructor( private readonly globalConfig: GlobalConfig, - private readonly instanceSettings: InstanceSettings, + private readonly instanceSettingsConfig: InstanceSettingsConfig, { isRoot }: { isRoot?: boolean } = { isRoot: true }, ) { this.level = this.globalConfig.logging.level; @@ -49,6 +55,8 @@ export class Logger { if (outputs.includes('file')) this.setFileTransport(); this.scopes = new Set(scopes); + } else { + this.scopes = new Set(); } if (isRoot) LoggerProxy.init(this); @@ -61,7 +69,9 @@ export class Logger { /** Create a logger that injects the given scopes into its log metadata. */ scoped(scopes: LogScope | LogScope[]) { scopes = Array.isArray(scopes) ? scopes : [scopes]; - const scopedLogger = new Logger(this.globalConfig, this.instanceSettings, { isRoot: false }); + const scopedLogger = new Logger(this.globalConfig, this.instanceSettingsConfig, { + isRoot: false, + }); const childLogger = this.internalLogger.child({ scopes }); scopedLogger.setInternalLogger(childLogger); @@ -107,10 +117,10 @@ export class Logger { } private scopeFilter() { - return winston.format((info: TransformableInfo & { metadata: LogMetadata }) => { + return winston.format((info: TransformableInfo) => { if (!this.isScopingEnabled) return info; - const { scopes } = info.metadata; + const { scopes } = (info as unknown as { metadata: LogMetadata }).metadata; const shouldIncludeScope = scopes && scopes?.length > 0 && scopes.some((s) => this.scopes.has(s)); @@ -179,7 +189,7 @@ export class Logger { ); const filename = path.join( - this.instanceSettings.n8nFolder, + this.instanceSettingsConfig.n8nFolder, this.globalConfig.logging.file.location, ); diff --git a/packages/core/src/node-execution-context/node-execution-context.ts b/packages/core/src/node-execution-context/node-execution-context.ts index 8477fe7856992..d303b10ba1b69 100644 --- a/packages/core/src/node-execution-context/node-execution-context.ts +++ b/packages/core/src/node-execution-context/node-execution-context.ts @@ -23,7 +23,6 @@ import { ApplicationError, deepCopy, ExpressionError, - LoggerProxy, NodeHelpers, NodeOperationError, } from 'n8n-workflow'; @@ -33,6 +32,7 @@ import { HTTP_REQUEST_NODE_TYPE, HTTP_REQUEST_TOOL_NODE_TYPE } from '@/Constants import { Memoized } from '@/decorators'; import { extractValue } from '@/ExtractValue'; import { InstanceSettings } from '@/InstanceSettings'; +import { Logger } from '@/logging/logger'; import { cleanupParameterData } from './utils/cleanupParameterData'; import { ensureType } from './utils/ensureType'; @@ -53,8 +53,9 @@ export abstract class NodeExecutionContext implements Omit { const userFolder = '/test'; @@ -11,12 +14,16 @@ describe('InstanceSettings', () => { const settingsFile = `${userFolder}/.n8n/config`; const mockFs = mock(fs); + const logger = mockInstance(Logger); const createInstanceSettings = (opts?: Partial) => - new InstanceSettings({ - ...new InstanceSettingsConfig(), - ...opts, - }); + new InstanceSettings( + { + ...new InstanceSettingsConfig(), + ...opts, + }, + logger, + ); beforeEach(() => { jest.resetAllMocks(); @@ -203,7 +210,7 @@ describe('InstanceSettings', () => { mockFs.readFileSync .calledWith(settingsFile) .mockReturnValue(JSON.stringify({ encryptionKey: 'test_key' })); - settings = new InstanceSettings(mock()); + settings = createInstanceSettings(); }); it('should return true if /.dockerenv exists', () => { diff --git a/packages/core/test/ObjectStore.service.test.ts b/packages/core/test/ObjectStore.service.test.ts index 77936c20f0bb5..9899ad17fc3cc 100644 --- a/packages/core/test/ObjectStore.service.test.ts +++ b/packages/core/test/ObjectStore.service.test.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import { mock } from 'jest-mock-extended'; import { Readable } from 'stream'; import { ObjectStoreService } from '@/ObjectStore/ObjectStore.service.ee'; @@ -25,7 +26,7 @@ const toDeletionXml = (filename: string) => ` let objectStoreService: ObjectStoreService; beforeEach(async () => { - objectStoreService = new ObjectStoreService(); + objectStoreService = new ObjectStoreService(mock()); mockAxios.request.mockResolvedValueOnce({ status: 200 }); // for checkConnection await objectStoreService.init(mockHost, mockBucket, mockCredentials); jest.restoreAllMocks(); diff --git a/packages/core/test/error-reporter.test.ts b/packages/core/test/error-reporter.test.ts index 1f507ab5c0081..7cd94fdb4b085 100644 --- a/packages/core/test/error-reporter.test.ts +++ b/packages/core/test/error-reporter.test.ts @@ -1,6 +1,7 @@ import { QueryFailedError } from '@n8n/typeorm'; import type { ErrorEvent } from '@sentry/types'; import { AxiosError } from 'axios'; +import { mock } from 'jest-mock-extended'; import { ApplicationError } from 'n8n-workflow'; import { ErrorReporter } from '@/error-reporter'; @@ -15,7 +16,7 @@ jest.mock('@sentry/node', () => ({ jest.spyOn(process, 'on'); describe('ErrorReporter', () => { - const errorReporter = new ErrorReporter(); + const errorReporter = new ErrorReporter(mock()); const event = {} as ErrorEvent; describe('beforeSend', () => { diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 401bb177c4cc5..654ae1be613ea 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -15,6 +15,7 @@ "include": ["src/**/*.ts", "test/**/*.ts"], "references": [ { "path": "../workflow/tsconfig.build.json" }, + { "path": "../@n8n/config/tsconfig.build.json" }, { "path": "../@n8n/client-oauth2/tsconfig.build.json" } ] } diff --git a/packages/nodes-base/nodes/Ldap/Helpers.ts b/packages/nodes-base/nodes/Ldap/Helpers.ts index 5e4447fa8463e..0b56b1b23057a 100644 --- a/packages/nodes-base/nodes/Ldap/Helpers.ts +++ b/packages/nodes-base/nodes/Ldap/Helpers.ts @@ -1,7 +1,6 @@ import { Client } from 'ldapts'; import type { ClientOptions, Entry } from 'ldapts'; -import type { ICredentialDataDecryptedObject, IDataObject } from 'n8n-workflow'; -import { LoggerProxy as Logger } from 'n8n-workflow'; +import type { ICredentialDataDecryptedObject, IDataObject, Logger } from 'n8n-workflow'; export const BINARY_AD_ATTRIBUTES = ['objectGUID', 'objectSid']; const resolveEntryBinaryAttributes = (entry: Entry): Entry => { @@ -18,6 +17,7 @@ export const resolveBinaryAttributes = (entries: Entry[]): void => { }; export async function createLdapClient( + context: { logger: Logger }, credentials: ICredentialDataDecryptedObject, nodeDebug?: boolean, nodeType?: string, @@ -45,7 +45,7 @@ export async function createLdapClient( } if (nodeDebug) { - Logger.info( + context.logger.info( `[${nodeType} | ${nodeName}] - LDAP Options: ${JSON.stringify(ldapOptions, null, 2)}`, ); } diff --git a/packages/nodes-base/nodes/Ldap/Ldap.node.ts b/packages/nodes-base/nodes/Ldap/Ldap.node.ts index 2d13e10314d0b..6c24606a67fbd 100644 --- a/packages/nodes-base/nodes/Ldap/Ldap.node.ts +++ b/packages/nodes-base/nodes/Ldap/Ldap.node.ts @@ -103,7 +103,7 @@ export class Ldap implements INodeType { credential: ICredentialsDecrypted, ): Promise { const credentials = credential.data as ICredentialDataDecryptedObject; - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); } catch (error) { @@ -123,7 +123,7 @@ export class Ldap implements INodeType { loadOptions: { async getAttributes(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); @@ -153,7 +153,7 @@ export class Ldap implements INodeType { async getObjectClasses(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); } catch (error) { @@ -196,7 +196,7 @@ export class Ldap implements INodeType { async getAttributesForDn(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); @@ -242,6 +242,7 @@ export class Ldap implements INodeType { const credentials = await this.getCredentials('ldap'); const client = await createLdapClient( + this, credentials, nodeDebug, this.getNode().type, diff --git a/packages/workflow/package.json b/packages/workflow/package.json index cabbeaaaaa618..3165343bd0a1d 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -31,6 +31,7 @@ ], "devDependencies": { "@langchain/core": "catalog:", + "@n8n/config": "workspace:*", "@types/deep-equal": "^1.0.1", "@types/express": "catalog:", "@types/jmespath": "^0.15.0", @@ -44,7 +45,7 @@ "@n8n_io/riot-tmpl": "4.0.0", "ast-types": "0.15.2", "axios": "catalog:", - "callsites": "3.1.0", + "callsites": "catalog:", "deep-equal": "2.2.0", "esprima-next": "5.8.4", "form-data": "catalog:", diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 6c28d4664dc2c..a67f7b59b498a 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ - import type { CallbackManager as CallbackManagerLC } from '@langchain/core/callbacks/manager'; +import type { LogScope } from '@n8n/config'; import type { AxiosProxyConfig, GenericAbortSignal } from 'axios'; import type * as express from 'express'; import type FormData from 'form-data'; @@ -675,6 +675,7 @@ export type ICredentialTestFunction = ( ) => Promise; export interface ICredentialTestFunctions { + logger: Logger; helpers: SSHTunnelFunctions & { request: (uriOrObject: string | object, options?: object) => Promise; }; @@ -2447,7 +2448,17 @@ export interface WorkflowTestData { } export type LogLevel = (typeof LOG_LEVELS)[number]; -export type Logger = Record, (message: string, meta?: object) => void>; +export type LogMetadata = { + [key: string]: unknown; + scopes?: LogScope[]; + file?: string; + function?: string; +}; +export type Logger = Record< + Exclude, + (message: string, metadata?: LogMetadata) => void +>; +export type LogLocationMetadata = Pick; export interface IStatusCodeMessages { [key: string]: string; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a42e5578268d6..bf87db10a9c4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,9 @@ catalogs: basic-auth: specifier: 2.0.1 version: 2.0.1 + callsites: + specifier: 3.1.0 + version: 3.1.0 fast-glob: specifier: 3.2.12 version: 3.2.12 @@ -54,6 +57,9 @@ catalogs: nanoid: specifier: 3.3.8 version: 3.3.8 + picocolors: + specifier: 1.0.1 + version: 1.0.1 typedi: specifier: 0.10.0 version: 0.10.0 @@ -811,9 +817,6 @@ importers: cache-manager: specifier: 5.2.3 version: 5.2.3 - callsites: - specifier: 3.1.0 - version: 3.1.0 change-case: specifier: 4.1.2 version: 4.1.2 @@ -947,7 +950,7 @@ importers: specifier: 8.12.0 version: 8.12.0 picocolors: - specifier: 1.0.1 + specifier: 'catalog:' version: 1.0.1 pkce-challenge: specifier: 3.0.0 @@ -1006,9 +1009,6 @@ importers: validator: specifier: 13.7.0 version: 13.7.0 - winston: - specifier: 3.14.2 - version: 3.14.2 ws: specifier: '>=8.17.1' version: 8.17.1 @@ -1136,6 +1136,9 @@ importers: axios: specifier: 'catalog:' version: 1.7.4 + callsites: + specifier: 'catalog:' + version: 3.1.0 chardet: specifier: 2.0.0 version: 2.0.0 @@ -1178,6 +1181,9 @@ importers: p-cancelable: specifier: 2.1.1 version: 2.1.1 + picocolors: + specifier: 'catalog:' + version: 1.0.1 pretty-bytes: specifier: 5.6.0 version: 5.6.0 @@ -1193,6 +1199,9 @@ importers: uuid: specifier: 'catalog:' version: 10.0.0 + winston: + specifier: 3.14.2 + version: 3.14.2 xml2js: specifier: 'catalog:' version: 0.6.2 @@ -1934,7 +1943,7 @@ importers: specifier: 'catalog:' version: 1.7.4 callsites: - specifier: 3.1.0 + specifier: 'catalog:' version: 3.1.0 deep-equal: specifier: 2.2.0 @@ -1979,6 +1988,9 @@ importers: '@langchain/core': specifier: 'catalog:' version: 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) + '@n8n/config': + specifier: workspace:* + version: link:../@n8n/config '@types/deep-equal': specifier: ^1.0.1 version: 1.0.1 @@ -14448,13 +14460,13 @@ snapshots: '@babel/code-frame@7.24.6': dependencies: '@babel/highlight': 7.24.6 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/code-frame@7.26.2': dependencies: '@babel/helper-validator-identifier': 7.25.9 js-tokens: 4.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/compat-data@7.23.5': {} @@ -14701,7 +14713,7 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 chalk: 2.4.2 js-tokens: 4.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/parser@7.25.6': dependencies: @@ -19415,7 +19427,7 @@ snapshots: caniuse-lite: 1.0.30001667 fraction.js: 4.3.7 normalize-range: 0.1.2 - picocolors: 1.0.1 + picocolors: 1.1.1 postcss: 8.4.38 postcss-value-parser: 4.2.0 @@ -19603,7 +19615,7 @@ snapshots: '@types/readable-stream': 4.0.10 buffer: 6.0.3 inherits: 2.0.4 - readable-stream: 4.4.2 + readable-stream: 4.5.2 blob-util@2.0.2: {} @@ -25032,13 +25044,13 @@ snapshots: postcss@8.4.31: dependencies: nanoid: 3.3.8 - picocolors: 1.0.1 + picocolors: 1.1.1 source-map-js: 1.2.1 postcss@8.4.38: dependencies: nanoid: 3.3.8 - picocolors: 1.0.1 + picocolors: 1.1.1 source-map-js: 1.2.0 postcss@8.4.49: @@ -26496,7 +26508,7 @@ snapshots: css-tree: 2.3.1 css-what: 6.1.0 csso: 5.0.5 - picocolors: 1.0.1 + picocolors: 1.1.1 swagger-ui-dist@5.11.0: {} @@ -26542,7 +26554,7 @@ snapshots: micromatch: 4.0.8 normalize-path: 3.0.0 object-hash: 3.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 postcss: 8.4.38 postcss-import: 15.1.0(postcss@8.4.38) postcss-js: 4.0.1(postcss@8.4.38) @@ -27094,7 +27106,7 @@ snapshots: dependencies: browserslist: 4.23.0 escalade: 3.1.1 - picocolors: 1.0.1 + picocolors: 1.1.1 update-browserslist-db@1.1.1(browserslist@4.24.2): dependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 6888cae7ae5f2..9700a3a45bbdc 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -13,6 +13,7 @@ catalog: '@types/xml2js': ^0.4.14 axios: 1.7.4 basic-auth: 2.0.1 + callsites: 3.1.0 chokidar: 4.0.1 fast-glob: 3.2.12 flatted: 3.2.7 @@ -21,6 +22,7 @@ catalog: lodash: 4.17.21 luxon: 3.4.4 nanoid: 3.3.8 + picocolors: 1.0.1 typedi: 0.10.0 uuid: 10.0.0 xml2js: 0.6.2 From f754b22a3f49c1528887c52902073ce3c0127645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 24 Dec 2024 13:02:05 +0100 Subject: [PATCH 02/43] refactor(core): Mark all backend Enterprise Edition files and dirs (#12350) --- LICENSE.md | 8 +++--- .../{combineScopes.ts => combineScopes.ee.ts} | 2 +- .../src/{constants.ts => constants.ee.ts} | 0 .../src/{hasScope.ts => hasScope.ee.ts} | 4 +-- packages/@n8n/permissions/src/index.ts | 8 +++--- .../permissions/src/{types.ts => types.ee.ts} | 2 +- .../@n8n/permissions/test/hasScope.test.ts | 4 +-- .../workflow-execute-additional-data.test.ts | 4 +-- packages/cli/src/auth/methods/email.ts | 2 +- packages/cli/src/auth/methods/ldap.ts | 4 +-- packages/cli/src/commands/base-command.ts | 4 +-- packages/cli/src/commands/ldap/reset.ts | 2 +- .../__tests__/users.controller.test.ts | 2 +- .../cli/src/controllers/auth.controller.ts | 2 +- .../src/controllers/invitation.controller.ts | 2 +- packages/cli/src/controllers/me.controller.ts | 2 +- .../oauth1-credential.controller.test.ts | 4 +-- .../oauth2-credential.controller.test.ts | 4 +-- .../controllers/password-reset.controller.ts | 2 +- .../cli/src/controllers/project.controller.ts | 2 +- .../cli/src/controllers/users.controller.ts | 2 +- .../src/credentials/credentials.service.ee.ts | 2 +- .../src/credentials/credentials.service.ts | 4 +-- packages/cli/src/databases/entities/user.ts | 2 +- .../1674509946020-CreateLdapEntities.ts | 2 +- .../shared-credentials.repository.test.ts | 2 +- .../repositories/settings.repository.ts | 2 +- .../cli/src/decorators/controller.registry.ts | 2 +- .../source-control-export.service.test.ts | 0 .../source-control-git.service.test.ts | 0 .../source-control-helper.ee.test.ts | 10 +++---- .../__tests__/source-control.service.test.ts | 4 +-- .../source-control/constants.ts | 0 .../source-control-enabled-middleware.ee.ts | 0 .../source-control-export.service.ee.ts | 0 .../source-control-git.service.ee.ts | 0 .../source-control-helper.ee.ts | 0 .../source-control-import.service.ee.ts | 0 .../source-control-preferences.service.ee.ts | 0 .../source-control.controller.ee.ts | 0 .../source-control.service.ee.ts | 0 .../source-control/types/export-result.ts | 0 .../types/exportable-credential.ts | 0 .../types/exportable-workflow.ts | 0 .../source-control/types/import-result.ts | 0 .../source-control/types/key-pair-type.ts | 0 .../source-control/types/key-pair.ts | 0 .../source-control/types/requests.ts | 0 .../source-control/types/resource-owner.ts | 0 .../types/source-control-commit.ts | 0 .../types/source-control-disconnect.ts | 0 .../types/source-control-generate-key-pair.ts | 0 .../types/source-control-get-status.ts | 0 .../types/source-control-preferences.ts | 0 .../types/source-control-pull-work-folder.ts | 0 .../types/source-control-push-work-folder.ts | 0 .../types/source-control-push.ts | 0 .../types/source-control-set-branch.ts | 0 .../types/source-control-set-read-only.ts | 0 .../types/source-control-stage.ts | 0 .../source-control-workflow-version-id.ts | 0 .../types/source-controlled-file.ts | 0 .../variables/environment-helpers.ts | 0 .../variables/variables.controller.ee.ts | 0 .../variables/variables.service.ee.ts | 0 .../metric.schema.ts | 0 .../metrics.controller.ts | 2 +- .../test-definition.schema.ts | 0 .../test-definition.service.ee.ts | 0 .../test-definitions.controller.ee.ts | 4 +-- .../test-definitions.types.ee.ts | 0 .../__tests__/create-pin-data.ee.test.ts | 0 .../__tests__/evaluation-metrics.ee.test.ts | 0 .../__tests__/get-start-node.ee.test.ts | 0 .../__tests__/mock-data/execution-data.json | 0 .../execution-data.multiple-triggers-2.json | 0 .../execution-data.multiple-triggers.json | 0 .../mock-data/workflow.evaluation.json | 0 .../mock-data/workflow.multiple-triggers.json | 0 .../mock-data/workflow.under-test.json | 0 .../__tests__/test-runner.service.ee.test.ts | 0 .../test-runner/evaluation-metrics.ee.ts | 0 .../test-runner/test-runner.service.ee.ts | 0 .../test-runner/utils.ee.ts | 0 .../test-runs.controller.ee.ts | 2 +- ...essage-event-bus-destination-webhook.ee.ts | 2 +- .../external-secrets-manager.ee.test.ts | 4 +-- .../constants.ts | 0 .../external-secrets-helper.ee.ts | 0 .../external-secrets-manager.ee.ts | 0 .../external-secrets-providers.ee.ts | 0 .../external-secrets.controller.ee.ts | 0 .../external-secrets.service.ee.ts | 0 .../__tests__/azure-key-vault.test.ts | 0 .../__tests__/gcp-secrets-manager.test.ts | 0 .../aws-secrets/aws-secrets-client.ts | 0 .../aws-secrets/aws-secrets-manager.ts | 2 +- .../providers/aws-secrets/types.ts | 0 .../azure-key-vault/azure-key-vault.ts | 2 +- .../providers/azure-key-vault/types.ts | 0 .../gcp-secrets-manager.ts | 2 +- .../providers/gcp-secrets-manager/types.ts | 0 .../providers/infisical.ts | 0 .../providers/vault.ts | 0 .../__tests__/helpers.test.ts | 2 +- .../cli/src/{ldap => ldap.ee}/constants.ts | 0 .../cli/src/{ldap => ldap.ee}/helpers.ee.ts | 0 .../{ldap => ldap.ee}/ldap.controller.ee.ts | 0 .../src/{ldap => ldap.ee}/ldap.service.ee.ts | 2 +- packages/cli/src/{ldap => ldap.ee}/types.ts | 0 .../check-access.ts | 0 .../global-roles.ts | 0 .../project-roles.ts | 0 .../resource-roles.ts | 0 .../source-control/source-control.handler.ts | 8 +++--- .../handlers/variables/variables.handler.ts | 2 +- .../handlers/workflows/workflows.handler.ts | 2 +- .../shared/middlewares/global.middleware.ts | 2 +- .../scaling/__tests__/pubsub-handler.test.ts | 4 +-- .../cli/src/scaling/pubsub/pubsub-handler.ts | 4 +-- ...service.ts => worker-status.service.ee.ts} | 0 ...crets-helpers.ts => secrets-helpers.ee.ts} | 2 +- packages/cli/src/server.ts | 26 +++++++++---------- .../__tests__/orchestration.service.test.ts | 2 +- packages/cli/src/services/frontend.service.ts | 10 +++---- ...oject.service.ts => project.service.ee.ts} | 0 packages/cli/src/services/role.service.ts | 6 ++--- .../saml/__tests__/saml-helpers.test.ts | 4 +-- .../saml/__tests__/saml-validator.test.ts | 0 .../saml/__tests__/saml.service.ee.test.ts | 4 +-- .../cli/src/{sso => sso.ee}/saml/constants.ts | 0 .../errors/invalid-saml-metadata.error.ts | 0 .../middleware/saml-enabled-middleware.ts | 0 .../__tests__/saml.controller.ee.test.ts | 0 .../saml/routes/saml.controller.ee.ts | 0 .../src/{sso => sso.ee}/saml/saml-helpers.ts | 0 .../{sso => sso.ee}/saml/saml-validator.ts | 0 .../{sso => sso.ee}/saml/saml.service.ee.ts | 0 .../saml/schema/metadata-exchange.xsd.ts | 0 ...is-200401-wss-wssecurity-secext-1.0.xsd.ts | 0 ...s-200401-wss-wssecurity-utility-1.0.xsd.ts | 0 .../schema/saml-schema-assertion-2.0.xsd.ts | 0 .../schema/saml-schema-metadata-2.0.xsd.ts | 0 .../schema/saml-schema-protocol-2.0.xsd.ts | 0 .../saml/schema/ws-addr.xsd.ts | 0 .../saml/schema/ws-authorization.xsd.ts | 0 .../saml/schema/ws-federation.xsd.ts | 0 .../saml/schema/ws-securitypolicy-1.2.xsd.ts | 0 .../saml/schema/xenc-schema.xsd.ts | 0 .../{sso => sso.ee}/saml/schema/xml.xsd.ts | 0 .../saml/schema/xmldsig-core-schema.xsd.ts | 0 .../saml/service-provider.ee.ts | 0 .../src/{sso => sso.ee}/saml/types/index.ts | 0 .../{sso => sso.ee}/saml/types/requests.ts | 0 .../saml/types/saml-attribute-mapping.ts | 0 .../saml/types/saml-preferences.ts | 0 .../saml/types/saml-user-attributes.ts | 0 .../saml/views/init-sso-post.ts | 0 .../cli/src/{sso => sso.ee}/sso-helpers.ts | 0 packages/cli/src/telemetry/index.ts | 2 +- .../src/user-management/permission-checker.ts | 2 +- .../src/workflow-execute-additional-data.ts | 2 +- packages/cli/src/workflow-helpers.ts | 2 +- .../workflow-history-helper.ee.test.ts | 2 +- .../workflow-history.service.ee.test.ts | 4 +-- .../workflow-history-helper.ee.ts | 0 .../workflow-history-manager.ee.ts | 0 .../workflow-history.controller.ee.ts | 0 .../workflow-history.service.ee.ts | 0 .../cli/src/workflows/workflow.service.ee.ts | 2 +- .../cli/src/workflows/workflow.service.ts | 4 +-- .../cli/src/workflows/workflows.controller.ts | 4 +-- .../active-workflow-manager.test.ts | 2 +- .../integration/commands/ldap/reset.test.ts | 4 +-- .../integration/commands/worker.cmd.test.ts | 2 +- .../credentials/credentials.api.ee.test.ts | 2 +- .../source-control-import.service.test.ts | 6 ++--- .../environments/source-control.test.ts | 6 ++--- .../evaluation/test-definitions.api.test.ts | 2 +- .../external-secrets.api.test.ts | 4 +-- .../test/integration/ldap/ldap.api.test.ts | 11 +++++--- .../integration/password-reset.api.test.ts | 2 +- .../project.service.integration.test.ts | 2 +- .../integration/public-api/workflows.test.ts | 2 +- .../integration/saml/saml-helpers.test.ts | 4 +-- .../test/integration/saml/saml.api.test.ts | 7 +++-- .../services/project.service.test.ts | 2 +- packages/cli/test/integration/shared/ldap.ts | 4 +-- .../integration/shared/utils/test-server.ts | 22 ++++++++-------- .../cli/test/integration/variables.test.ts | 2 +- .../workflow-history-manager.test.ts | 2 +- .../workflow-sharing.service.test.ts | 2 +- .../workflows/workflows.controller.test.ts | 2 +- packages/cli/tsconfig.json | 2 +- 194 files changed, 161 insertions(+), 153 deletions(-) rename packages/@n8n/permissions/src/{combineScopes.ts => combineScopes.ee.ts} (98%) rename packages/@n8n/permissions/src/{constants.ts => constants.ee.ts} (100%) rename packages/@n8n/permissions/src/{hasScope.ts => hasScope.ee.ts} (90%) rename packages/@n8n/permissions/src/{types.ts => types.ee.ts} (96%) rename packages/cli/src/{environments => environments.ee}/source-control/__tests__/source-control-export.service.test.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/__tests__/source-control-git.service.test.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/__tests__/source-control-helper.ee.test.ts (93%) rename packages/cli/src/{environments => environments.ee}/source-control/__tests__/source-control.service.test.ts (82%) rename packages/cli/src/{environments => environments.ee}/source-control/constants.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/middleware/source-control-enabled-middleware.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control-export.service.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control-git.service.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control-helper.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control-import.service.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control-preferences.service.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control.controller.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/source-control.service.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/export-result.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/exportable-credential.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/exportable-workflow.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/import-result.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/key-pair-type.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/key-pair.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/requests.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/resource-owner.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-commit.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-disconnect.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-generate-key-pair.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-get-status.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-preferences.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-pull-work-folder.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-push-work-folder.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-push.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-set-branch.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-set-read-only.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-stage.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-control-workflow-version-id.ts (100%) rename packages/cli/src/{environments => environments.ee}/source-control/types/source-controlled-file.ts (100%) rename packages/cli/src/{environments => environments.ee}/variables/environment-helpers.ts (100%) rename packages/cli/src/{environments => environments.ee}/variables/variables.controller.ee.ts (100%) rename packages/cli/src/{environments => environments.ee}/variables/variables.service.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/metric.schema.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/metrics.controller.ts (99%) rename packages/cli/src/{evaluation => evaluation.ee}/test-definition.schema.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-definition.service.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-definitions.controller.ee.ts (97%) rename packages/cli/src/{evaluation => evaluation.ee}/test-definitions.types.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/create-pin-data.ee.test.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/evaluation-metrics.ee.test.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/get-start-node.ee.test.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/execution-data.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/workflow.evaluation.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/workflow.multiple-triggers.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/mock-data/workflow.under-test.json (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/__tests__/test-runner.service.ee.test.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/evaluation-metrics.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/test-runner.service.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runner/utils.ee.ts (100%) rename packages/cli/src/{evaluation => evaluation.ee}/test-runs.controller.ee.ts (96%) rename packages/cli/src/{external-secrets => external-secrets.ee}/__tests__/external-secrets-manager.ee.test.ts (95%) rename packages/cli/src/{external-secrets => external-secrets.ee}/constants.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/external-secrets-helper.ee.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/external-secrets-manager.ee.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/external-secrets-providers.ee.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/external-secrets.controller.ee.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/external-secrets.service.ee.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/__tests__/azure-key-vault.test.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/__tests__/gcp-secrets-manager.test.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/aws-secrets/aws-secrets-client.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/aws-secrets/aws-secrets-manager.ts (99%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/aws-secrets/types.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/azure-key-vault/azure-key-vault.ts (99%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/azure-key-vault/types.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/gcp-secrets-manager/gcp-secrets-manager.ts (99%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/gcp-secrets-manager/types.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/infisical.ts (100%) rename packages/cli/src/{external-secrets => external-secrets.ee}/providers/vault.ts (100%) rename packages/cli/src/{ldap => ldap.ee}/__tests__/helpers.test.ts (96%) rename packages/cli/src/{ldap => ldap.ee}/constants.ts (100%) rename packages/cli/src/{ldap => ldap.ee}/helpers.ee.ts (100%) rename packages/cli/src/{ldap => ldap.ee}/ldap.controller.ee.ts (100%) rename packages/cli/src/{ldap => ldap.ee}/ldap.service.ee.ts (99%) rename packages/cli/src/{ldap => ldap.ee}/types.ts (100%) rename packages/cli/src/{permissions => permissions.ee}/check-access.ts (100%) rename packages/cli/src/{permissions => permissions.ee}/global-roles.ts (100%) rename packages/cli/src/{permissions => permissions.ee}/project-roles.ts (100%) rename packages/cli/src/{permissions => permissions.ee}/resource-roles.ts (100%) rename packages/cli/src/scaling/{worker-status.service.ts => worker-status.service.ee.ts} (100%) rename packages/cli/src/{secrets-helpers.ts => secrets-helpers.ee.ts} (90%) rename packages/cli/src/services/{project.service.ts => project.service.ee.ts} (100%) rename packages/cli/src/{sso => sso.ee}/saml/__tests__/saml-helpers.test.ts (92%) rename packages/cli/src/{sso => sso.ee}/saml/__tests__/saml-validator.test.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/__tests__/saml.service.ee.test.ts (97%) rename packages/cli/src/{sso => sso.ee}/saml/constants.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/errors/invalid-saml-metadata.error.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/middleware/saml-enabled-middleware.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/routes/__tests__/saml.controller.ee.test.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/routes/saml.controller.ee.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/saml-helpers.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/saml-validator.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/saml.service.ee.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/metadata-exchange.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/saml-schema-assertion-2.0.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/saml-schema-metadata-2.0.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/saml-schema-protocol-2.0.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/ws-addr.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/ws-authorization.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/ws-federation.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/ws-securitypolicy-1.2.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/xenc-schema.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/xml.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/schema/xmldsig-core-schema.xsd.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/service-provider.ee.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/types/index.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/types/requests.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/types/saml-attribute-mapping.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/types/saml-preferences.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/types/saml-user-attributes.ts (100%) rename packages/cli/src/{sso => sso.ee}/saml/views/init-sso-post.ts (100%) rename packages/cli/src/{sso => sso.ee}/sso-helpers.ts (100%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/__tests__/workflow-history-helper.ee.test.ts (97%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/__tests__/workflow-history.service.ee.test.ts (96%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/workflow-history-helper.ee.ts (100%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/workflow-history-manager.ee.ts (100%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/workflow-history.controller.ee.ts (100%) rename packages/cli/src/workflows/{workflow-history => workflow-history.ee}/workflow-history.service.ee.ts (100%) diff --git a/LICENSE.md b/LICENSE.md index aab68b6d9301b..f85f59baa9065 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -3,9 +3,11 @@ Portions of this software are licensed as follows: - Content of branches other than the main branch (i.e. "master") are not licensed. -- Source code files that contain ".ee." in their filename are NOT licensed under the Sustainable Use License. - To use source code files that contain ".ee." in their filename you must hold a valid n8n Enterprise License - specifically allowing you access to such source code files and as defined in "LICENSE_EE.md". +- Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under + the Sustainable Use License. + To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a + valid n8n Enterprise License specifically allowing you access to such source code files and as defined + in "LICENSE_EE.md". - All third party components incorporated into the n8n Software are licensed under the original license provided by the owner of the applicable component. - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use diff --git a/packages/@n8n/permissions/src/combineScopes.ts b/packages/@n8n/permissions/src/combineScopes.ee.ts similarity index 98% rename from packages/@n8n/permissions/src/combineScopes.ts rename to packages/@n8n/permissions/src/combineScopes.ee.ts index 23da64d8379bc..96a43b940cd89 100644 --- a/packages/@n8n/permissions/src/combineScopes.ts +++ b/packages/@n8n/permissions/src/combineScopes.ee.ts @@ -1,4 +1,4 @@ -import type { Scope, ScopeLevels, GlobalScopes, MaskLevels } from './types'; +import type { Scope, ScopeLevels, GlobalScopes, MaskLevels } from './types.ee'; export function combineScopes(userScopes: GlobalScopes, masks?: MaskLevels): Set; export function combineScopes(userScopes: ScopeLevels, masks?: MaskLevels): Set; diff --git a/packages/@n8n/permissions/src/constants.ts b/packages/@n8n/permissions/src/constants.ee.ts similarity index 100% rename from packages/@n8n/permissions/src/constants.ts rename to packages/@n8n/permissions/src/constants.ee.ts diff --git a/packages/@n8n/permissions/src/hasScope.ts b/packages/@n8n/permissions/src/hasScope.ee.ts similarity index 90% rename from packages/@n8n/permissions/src/hasScope.ts rename to packages/@n8n/permissions/src/hasScope.ee.ts index d449283490991..81bcbc5175d86 100644 --- a/packages/@n8n/permissions/src/hasScope.ts +++ b/packages/@n8n/permissions/src/hasScope.ee.ts @@ -1,5 +1,5 @@ -import { combineScopes } from './combineScopes'; -import type { Scope, ScopeLevels, GlobalScopes, ScopeOptions, MaskLevels } from './types'; +import { combineScopes } from './combineScopes.ee'; +import type { Scope, ScopeLevels, GlobalScopes, ScopeOptions, MaskLevels } from './types.ee'; export function hasScope( scope: Scope | Scope[], diff --git a/packages/@n8n/permissions/src/index.ts b/packages/@n8n/permissions/src/index.ts index f04f2e4ef68ac..ae20358303a6b 100644 --- a/packages/@n8n/permissions/src/index.ts +++ b/packages/@n8n/permissions/src/index.ts @@ -1,4 +1,4 @@ -export type * from './types'; -export * from './constants'; -export * from './hasScope'; -export * from './combineScopes'; +export type * from './types.ee'; +export * from './constants.ee'; +export * from './hasScope.ee'; +export * from './combineScopes.ee'; diff --git a/packages/@n8n/permissions/src/types.ts b/packages/@n8n/permissions/src/types.ee.ts similarity index 96% rename from packages/@n8n/permissions/src/types.ts rename to packages/@n8n/permissions/src/types.ee.ts index b36fb792ae435..db74668fbe9fc 100644 --- a/packages/@n8n/permissions/src/types.ts +++ b/packages/@n8n/permissions/src/types.ee.ts @@ -1,4 +1,4 @@ -import type { RESOURCES } from './constants'; +import type { RESOURCES } from './constants.ee'; export type Resource = keyof typeof RESOURCES; diff --git a/packages/@n8n/permissions/test/hasScope.test.ts b/packages/@n8n/permissions/test/hasScope.test.ts index 0e43bc8dc639e..b3362e4ea64f5 100644 --- a/packages/@n8n/permissions/test/hasScope.test.ts +++ b/packages/@n8n/permissions/test/hasScope.test.ts @@ -1,5 +1,5 @@ -import { hasScope } from '@/hasScope'; -import type { Scope } from '@/types'; +import { hasScope } from '@/hasScope.ee'; +import type { Scope } from '@/types.ee'; const ownerPermissions: Scope[] = [ 'workflow:create', diff --git a/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts b/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts index e7d94d3e34e04..641e2393931e6 100644 --- a/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts +++ b/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts @@ -15,10 +15,10 @@ import { CredentialsHelper } from '@/credentials-helper'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { VariablesService } from '@/environments/variables/variables.service.ee'; +import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import { SecretsHelper } from '@/secrets-helpers'; +import { SecretsHelper } from '@/secrets-helpers.ee'; import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; import { SubworkflowPolicyChecker } from '@/subworkflows/subworkflow-policy-checker.service'; import { Telemetry } from '@/telemetry'; diff --git a/packages/cli/src/auth/methods/email.ts b/packages/cli/src/auth/methods/email.ts index 723365057f66c..6f378e4357a89 100644 --- a/packages/cli/src/auth/methods/email.ts +++ b/packages/cli/src/auth/methods/email.ts @@ -4,7 +4,7 @@ import type { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { EventService } from '@/events/event.service'; -import { isLdapLoginEnabled } from '@/ldap/helpers.ee'; +import { isLdapLoginEnabled } from '@/ldap.ee/helpers.ee'; import { PasswordUtility } from '@/services/password.utility'; export const handleEmailLogin = async ( diff --git a/packages/cli/src/auth/methods/ldap.ts b/packages/cli/src/auth/methods/ldap.ts index b8fea259891f8..f067994215424 100644 --- a/packages/cli/src/auth/methods/ldap.ts +++ b/packages/cli/src/auth/methods/ldap.ts @@ -10,8 +10,8 @@ import { mapLdapAttributesToUser, createLdapAuthIdentity, updateLdapUserOnLocalDb, -} from '@/ldap/helpers.ee'; -import { LdapService } from '@/ldap/ldap.service.ee'; +} from '@/ldap.ee/helpers.ee'; +import { LdapService } from '@/ldap.ee/ldap.service.ee'; export const handleLdapLogin = async ( loginId: string, diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index a10c386f4222f..7692ef79bed40 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -23,13 +23,13 @@ import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus' import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay'; import { initExpressionEvaluator } from '@/expression-evaluator'; import { ExternalHooks } from '@/external-hooks'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { NodeTypes } from '@/node-types'; import { PostHogClient } from '@/posthog'; import { ShutdownService } from '@/shutdown/shutdown.service'; -import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; +import { WorkflowHistoryManager } from '@/workflows/workflow-history.ee/workflow-history-manager.ee'; export abstract class BaseCommand extends Command { protected logger = Container.get(Logger); diff --git a/packages/cli/src/commands/ldap/reset.ts b/packages/cli/src/commands/ldap/reset.ts index f9f1f3d0bb8bf..6aaaa217d60ce 100644 --- a/packages/cli/src/commands/ldap/reset.ts +++ b/packages/cli/src/commands/ldap/reset.ts @@ -14,7 +14,7 @@ import { SettingsRepository } from '@/databases/repositories/settings.repository import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap.ee/constants'; import { WorkflowService } from '@/workflows/workflow.service'; import { BaseCommand } from '../base-command'; diff --git a/packages/cli/src/controllers/__tests__/users.controller.test.ts b/packages/cli/src/controllers/__tests__/users.controller.test.ts index 91ad6bd28b299..5eaaca58406d2 100644 --- a/packages/cli/src/controllers/__tests__/users.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/users.controller.test.ts @@ -4,7 +4,7 @@ import type { User } from '@/databases/entities/user'; import type { UserRepository } from '@/databases/repositories/user.repository'; import type { EventService } from '@/events/event.service'; import type { AuthenticatedRequest } from '@/requests'; -import type { ProjectService } from '@/services/project.service'; +import type { ProjectService } from '@/services/project.service.ee'; import { UsersController } from '../users.controller'; diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index faf24ed669bdd..b012e571312ab 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -23,7 +23,7 @@ import { getCurrentAuthenticationMethod, isLdapCurrentAuthenticationMethod, isSamlCurrentAuthenticationMethod, -} from '@/sso/sso-helpers'; +} from '@/sso.ee/sso-helpers'; @RestController() export class AuthController { diff --git a/packages/cli/src/controllers/invitation.controller.ts b/packages/cli/src/controllers/invitation.controller.ts index 24cff10c643f5..d28b0671e0718 100644 --- a/packages/cli/src/controllers/invitation.controller.ts +++ b/packages/cli/src/controllers/invitation.controller.ts @@ -17,7 +17,7 @@ import { PostHogClient } from '@/posthog'; import { UserRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; -import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; +import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers'; @RestController('/invitations') export class InvitationController { diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index f56d62aebd559..5de2e49e967be 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -21,7 +21,7 @@ import { MfaService } from '@/mfa/mfa.service'; import { AuthenticatedRequest, MeRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; -import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; +import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers'; import { PersonalizationSurveyAnswersV4 } from './survey-answers.dto'; @RestController('/me') diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts index c7990ddbfdc6a..0c51f29f22f64 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts @@ -13,12 +13,12 @@ import type { CredentialsEntity } from '@/databases/entities/credentials-entity' import type { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { VariablesService } from '@/environments/variables/variables.service.ee'; +import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import type { OAuthRequest } from '@/requests'; -import { SecretsHelper } from '@/secrets-helpers'; +import { SecretsHelper } from '@/secrets-helpers.ee'; import { mockInstance } from '@test/mocking'; describe('OAuth1CredentialController', () => { diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts index ca9e4db5c6b42..c1c240425e65e 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts @@ -13,12 +13,12 @@ import type { CredentialsEntity } from '@/databases/entities/credentials-entity' import type { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { VariablesService } from '@/environments/variables/variables.service.ee'; +import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import type { OAuthRequest } from '@/requests'; -import { SecretsHelper } from '@/secrets-helpers'; +import { SecretsHelper } from '@/secrets-helpers.ee'; import { mockInstance } from '@test/mocking'; describe('OAuth2CredentialController', () => { diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index cb5e2c6f8b72f..7fc266c8e84e3 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -18,7 +18,7 @@ import { MfaService } from '@/mfa/mfa.service'; import { PasswordResetRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; -import { isSamlCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { isSamlCurrentAuthenticationMethod } from '@/sso.ee/sso-helpers'; import { UserManagementMailer } from '@/user-management/email'; @RestController() diff --git a/packages/cli/src/controllers/project.controller.ts b/packages/cli/src/controllers/project.controller.ts index 415e0e9519130..d16883f3dd5eb 100644 --- a/packages/cli/src/controllers/project.controller.ts +++ b/packages/cli/src/controllers/project.controller.ts @@ -23,7 +23,7 @@ import { ProjectService, TeamProjectOverQuotaError, UnlicensedProjectRoleError, -} from '@/services/project.service'; +} from '@/services/project.service.ee'; import { RoleService } from '@/services/role.service'; @RestController('/projects') diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index 4cfa18a1e3396..e290d294638f2 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -21,7 +21,7 @@ import { ExternalHooks } from '@/external-hooks'; import type { PublicUser } from '@/interfaces'; import { listQueryMiddleware } from '@/middlewares'; import { AuthenticatedRequest, ListQuery, UserRequest } from '@/requests'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { UserService } from '@/services/user.service'; import { WorkflowService } from '@/workflows/workflow.service'; diff --git a/packages/cli/src/credentials/credentials.service.ee.ts b/packages/cli/src/credentials/credentials.service.ee.ts index aad78fe7b7303..274feff81b6c4 100644 --- a/packages/cli/src/credentials/credentials.service.ee.ts +++ b/packages/cli/src/credentials/credentials.service.ee.ts @@ -11,7 +11,7 @@ import { SharedCredentialsRepository } from '@/databases/repositories/shared-cre import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { TransferCredentialError } from '@/errors/response-errors/transfer-credential.error'; import { OwnershipService } from '@/services/ownership.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { RoleService } from '@/services/role.service'; import { CredentialsService } from './credentials.service'; diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index 8261b1364974f..3525aecbe908b 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -33,11 +33,11 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { ICredentialsDb } from '@/interfaces'; -import { userHasScopes } from '@/permissions/check-access'; +import { userHasScopes } from '@/permissions.ee/check-access'; import type { CredentialRequest, ListQuery } from '@/requests'; import { CredentialsTester } from '@/services/credentials-tester.service'; import { OwnershipService } from '@/services/ownership.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { RoleService } from '@/services/role.service'; export type CredentialsGetSharedOptions = diff --git a/packages/cli/src/databases/entities/user.ts b/packages/cli/src/databases/entities/user.ts index b75bec757ccc3..5aae21d003ff6 100644 --- a/packages/cli/src/databases/entities/user.ts +++ b/packages/cli/src/databases/entities/user.ts @@ -18,7 +18,7 @@ import { GLOBAL_OWNER_SCOPES, GLOBAL_MEMBER_SCOPES, GLOBAL_ADMIN_SCOPES, -} from '@/permissions/global-roles'; +} from '@/permissions.ee/global-roles'; import { NoUrl } from '@/validators/no-url.validator'; import { NoXss } from '@/validators/no-xss.validator'; diff --git a/packages/cli/src/databases/migrations/common/1674509946020-CreateLdapEntities.ts b/packages/cli/src/databases/migrations/common/1674509946020-CreateLdapEntities.ts index 5ccd0c40a47bb..95a2c11a51f2f 100644 --- a/packages/cli/src/databases/migrations/common/1674509946020-CreateLdapEntities.ts +++ b/packages/cli/src/databases/migrations/common/1674509946020-CreateLdapEntities.ts @@ -1,5 +1,5 @@ import type { MigrationContext, ReversibleMigration } from '@/databases/types'; -import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap.ee/constants'; export class CreateLdapEntities1674509946020 implements ReversibleMigration { async up({ escape, dbType, isMysql, runQuery }: MigrationContext) { diff --git a/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts index afaca2206f129..5f8b441235c2f 100644 --- a/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts @@ -7,7 +7,7 @@ import type { CredentialsEntity } from '@/databases/entities/credentials-entity' import { SharedCredentials } from '@/databases/entities/shared-credentials'; import type { User } from '@/databases/entities/user'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { GLOBAL_MEMBER_SCOPES, GLOBAL_OWNER_SCOPES } from '@/permissions/global-roles'; +import { GLOBAL_MEMBER_SCOPES, GLOBAL_OWNER_SCOPES } from '@/permissions.ee/global-roles'; import { mockEntityManager } from '@test/mocking'; describe('SharedCredentialsRepository', () => { diff --git a/packages/cli/src/databases/repositories/settings.repository.ts b/packages/cli/src/databases/repositories/settings.repository.ts index aa4410d6d48fe..a00f52b4e7b4d 100644 --- a/packages/cli/src/databases/repositories/settings.repository.ts +++ b/packages/cli/src/databases/repositories/settings.repository.ts @@ -3,7 +3,7 @@ import { ErrorReporter } from 'n8n-core'; import { Service } from 'typedi'; import config from '@/config'; -import { EXTERNAL_SECRETS_DB_KEY } from '@/external-secrets/constants'; +import { EXTERNAL_SECRETS_DB_KEY } from '@/external-secrets.ee/constants'; import { Settings } from '../entities/settings'; diff --git a/packages/cli/src/decorators/controller.registry.ts b/packages/cli/src/decorators/controller.registry.ts index 3a22090db1469..fd0cbf4eec7c3 100644 --- a/packages/cli/src/decorators/controller.registry.ts +++ b/packages/cli/src/decorators/controller.registry.ts @@ -11,7 +11,7 @@ import { inProduction, RESPONSE_ERROR_MESSAGES } from '@/constants'; import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error'; import type { BooleanLicenseFeature } from '@/interfaces'; import { License } from '@/license'; -import { userHasScopes } from '@/permissions/check-access'; +import { userHasScopes } from '@/permissions.ee/check-access'; import type { AuthenticatedRequest } from '@/requests'; import { send } from '@/response-helper'; // TODO: move `ResponseHelper.send` to this file diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts b/packages/cli/src/environments.ee/source-control/__tests__/source-control-export.service.test.ts similarity index 100% rename from packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts rename to packages/cli/src/environments.ee/source-control/__tests__/source-control-export.service.test.ts diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts b/packages/cli/src/environments.ee/source-control/__tests__/source-control-git.service.test.ts similarity index 100% rename from packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts rename to packages/cli/src/environments.ee/source-control/__tests__/source-control-git.service.test.ts diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts b/packages/cli/src/environments.ee/source-control/__tests__/source-control-helper.ee.test.ts similarity index 93% rename from packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts rename to packages/cli/src/environments.ee/source-control/__tests__/source-control-helper.ee.test.ts index 508d1eb49a4bd..5ecb04cf8ad33 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts +++ b/packages/cli/src/environments.ee/source-control/__tests__/source-control-helper.ee.test.ts @@ -6,7 +6,7 @@ import Container from 'typedi'; import { SOURCE_CONTROL_SSH_FOLDER, SOURCE_CONTROL_GIT_FOLDER, -} from '@/environments/source-control/constants'; +} from '@/environments.ee/source-control/constants'; import { generateSshKeyPair, getRepoType, @@ -14,10 +14,10 @@ import { getTrackingInformationFromPrePushResult, getTrackingInformationFromPullResult, sourceControlFoldersExistCheck, -} from '@/environments/source-control/source-control-helper.ee'; -import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; -import type { SourceControlPreferences } from '@/environments/source-control/types/source-control-preferences'; -import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +} from '@/environments.ee/source-control/source-control-helper.ee'; +import { SourceControlPreferencesService } from '@/environments.ee/source-control/source-control-preferences.service.ee'; +import type { SourceControlPreferences } from '@/environments.ee/source-control/types/source-control-preferences'; +import type { SourceControlledFile } from '@/environments.ee/source-control/types/source-controlled-file'; import { License } from '@/license'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts b/packages/cli/src/environments.ee/source-control/__tests__/source-control.service.test.ts similarity index 82% rename from packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts rename to packages/cli/src/environments.ee/source-control/__tests__/source-control.service.test.ts index 1599f7b4bde3a..8b32062d55a8d 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts +++ b/packages/cli/src/environments.ee/source-control/__tests__/source-control.service.test.ts @@ -2,8 +2,8 @@ import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; import { Container } from 'typedi'; -import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; -import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; +import { SourceControlPreferencesService } from '@/environments.ee/source-control/source-control-preferences.service.ee'; +import { SourceControlService } from '@/environments.ee/source-control/source-control.service.ee'; describe('SourceControlService', () => { const preferencesService = new SourceControlPreferencesService( diff --git a/packages/cli/src/environments/source-control/constants.ts b/packages/cli/src/environments.ee/source-control/constants.ts similarity index 100% rename from packages/cli/src/environments/source-control/constants.ts rename to packages/cli/src/environments.ee/source-control/constants.ts diff --git a/packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts b/packages/cli/src/environments.ee/source-control/middleware/source-control-enabled-middleware.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts rename to packages/cli/src/environments.ee/source-control/middleware/source-control-enabled-middleware.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control-export.service.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-git.service.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control-git.service.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control-git.service.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control-helper.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-helper.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control-helper.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control-helper.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-import.service.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control-import.service.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control-import.service.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-preferences.service.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control-preferences.service.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control.controller.ee.ts b/packages/cli/src/environments.ee/source-control/source-control.controller.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control.controller.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control.controller.ee.ts diff --git a/packages/cli/src/environments/source-control/source-control.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control.service.ee.ts similarity index 100% rename from packages/cli/src/environments/source-control/source-control.service.ee.ts rename to packages/cli/src/environments.ee/source-control/source-control.service.ee.ts diff --git a/packages/cli/src/environments/source-control/types/export-result.ts b/packages/cli/src/environments.ee/source-control/types/export-result.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/export-result.ts rename to packages/cli/src/environments.ee/source-control/types/export-result.ts diff --git a/packages/cli/src/environments/source-control/types/exportable-credential.ts b/packages/cli/src/environments.ee/source-control/types/exportable-credential.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/exportable-credential.ts rename to packages/cli/src/environments.ee/source-control/types/exportable-credential.ts diff --git a/packages/cli/src/environments/source-control/types/exportable-workflow.ts b/packages/cli/src/environments.ee/source-control/types/exportable-workflow.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/exportable-workflow.ts rename to packages/cli/src/environments.ee/source-control/types/exportable-workflow.ts diff --git a/packages/cli/src/environments/source-control/types/import-result.ts b/packages/cli/src/environments.ee/source-control/types/import-result.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/import-result.ts rename to packages/cli/src/environments.ee/source-control/types/import-result.ts diff --git a/packages/cli/src/environments/source-control/types/key-pair-type.ts b/packages/cli/src/environments.ee/source-control/types/key-pair-type.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/key-pair-type.ts rename to packages/cli/src/environments.ee/source-control/types/key-pair-type.ts diff --git a/packages/cli/src/environments/source-control/types/key-pair.ts b/packages/cli/src/environments.ee/source-control/types/key-pair.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/key-pair.ts rename to packages/cli/src/environments.ee/source-control/types/key-pair.ts diff --git a/packages/cli/src/environments/source-control/types/requests.ts b/packages/cli/src/environments.ee/source-control/types/requests.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/requests.ts rename to packages/cli/src/environments.ee/source-control/types/requests.ts diff --git a/packages/cli/src/environments/source-control/types/resource-owner.ts b/packages/cli/src/environments.ee/source-control/types/resource-owner.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/resource-owner.ts rename to packages/cli/src/environments.ee/source-control/types/resource-owner.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-commit.ts b/packages/cli/src/environments.ee/source-control/types/source-control-commit.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-commit.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-commit.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-disconnect.ts b/packages/cli/src/environments.ee/source-control/types/source-control-disconnect.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-disconnect.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-disconnect.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts b/packages/cli/src/environments.ee/source-control/types/source-control-generate-key-pair.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-generate-key-pair.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-get-status.ts b/packages/cli/src/environments.ee/source-control/types/source-control-get-status.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-get-status.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-get-status.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-preferences.ts b/packages/cli/src/environments.ee/source-control/types/source-control-preferences.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-preferences.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-preferences.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-pull-work-folder.ts b/packages/cli/src/environments.ee/source-control/types/source-control-pull-work-folder.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-pull-work-folder.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-pull-work-folder.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts b/packages/cli/src/environments.ee/source-control/types/source-control-push-work-folder.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-push-work-folder.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-push.ts b/packages/cli/src/environments.ee/source-control/types/source-control-push.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-push.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-push.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-set-branch.ts b/packages/cli/src/environments.ee/source-control/types/source-control-set-branch.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-set-branch.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-set-branch.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-set-read-only.ts b/packages/cli/src/environments.ee/source-control/types/source-control-set-read-only.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-set-read-only.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-set-read-only.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-stage.ts b/packages/cli/src/environments.ee/source-control/types/source-control-stage.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-stage.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-stage.ts diff --git a/packages/cli/src/environments/source-control/types/source-control-workflow-version-id.ts b/packages/cli/src/environments.ee/source-control/types/source-control-workflow-version-id.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-control-workflow-version-id.ts rename to packages/cli/src/environments.ee/source-control/types/source-control-workflow-version-id.ts diff --git a/packages/cli/src/environments/source-control/types/source-controlled-file.ts b/packages/cli/src/environments.ee/source-control/types/source-controlled-file.ts similarity index 100% rename from packages/cli/src/environments/source-control/types/source-controlled-file.ts rename to packages/cli/src/environments.ee/source-control/types/source-controlled-file.ts diff --git a/packages/cli/src/environments/variables/environment-helpers.ts b/packages/cli/src/environments.ee/variables/environment-helpers.ts similarity index 100% rename from packages/cli/src/environments/variables/environment-helpers.ts rename to packages/cli/src/environments.ee/variables/environment-helpers.ts diff --git a/packages/cli/src/environments/variables/variables.controller.ee.ts b/packages/cli/src/environments.ee/variables/variables.controller.ee.ts similarity index 100% rename from packages/cli/src/environments/variables/variables.controller.ee.ts rename to packages/cli/src/environments.ee/variables/variables.controller.ee.ts diff --git a/packages/cli/src/environments/variables/variables.service.ee.ts b/packages/cli/src/environments.ee/variables/variables.service.ee.ts similarity index 100% rename from packages/cli/src/environments/variables/variables.service.ee.ts rename to packages/cli/src/environments.ee/variables/variables.service.ee.ts diff --git a/packages/cli/src/evaluation/metric.schema.ts b/packages/cli/src/evaluation.ee/metric.schema.ts similarity index 100% rename from packages/cli/src/evaluation/metric.schema.ts rename to packages/cli/src/evaluation.ee/metric.schema.ts diff --git a/packages/cli/src/evaluation/metrics.controller.ts b/packages/cli/src/evaluation.ee/metrics.controller.ts similarity index 99% rename from packages/cli/src/evaluation/metrics.controller.ts rename to packages/cli/src/evaluation.ee/metrics.controller.ts index 816228bf13494..2072b978b1ba9 100644 --- a/packages/cli/src/evaluation/metrics.controller.ts +++ b/packages/cli/src/evaluation.ee/metrics.controller.ts @@ -6,7 +6,7 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { testMetricCreateRequestBodySchema, testMetricPatchRequestBodySchema, -} from '@/evaluation/metric.schema'; +} from '@/evaluation.ee/metric.schema'; import { getSharedWorkflowIds } from '@/public-api/v1/handlers/workflows/workflows.service'; import { TestDefinitionService } from './test-definition.service.ee'; diff --git a/packages/cli/src/evaluation/test-definition.schema.ts b/packages/cli/src/evaluation.ee/test-definition.schema.ts similarity index 100% rename from packages/cli/src/evaluation/test-definition.schema.ts rename to packages/cli/src/evaluation.ee/test-definition.schema.ts diff --git a/packages/cli/src/evaluation/test-definition.service.ee.ts b/packages/cli/src/evaluation.ee/test-definition.service.ee.ts similarity index 100% rename from packages/cli/src/evaluation/test-definition.service.ee.ts rename to packages/cli/src/evaluation.ee/test-definition.service.ee.ts diff --git a/packages/cli/src/evaluation/test-definitions.controller.ee.ts b/packages/cli/src/evaluation.ee/test-definitions.controller.ee.ts similarity index 97% rename from packages/cli/src/evaluation/test-definitions.controller.ee.ts rename to packages/cli/src/evaluation.ee/test-definitions.controller.ee.ts index ef4a3ed4613a6..bd4a841948e73 100644 --- a/packages/cli/src/evaluation/test-definitions.controller.ee.ts +++ b/packages/cli/src/evaluation.ee/test-definitions.controller.ee.ts @@ -7,8 +7,8 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { testDefinitionCreateRequestBodySchema, testDefinitionPatchRequestBodySchema, -} from '@/evaluation/test-definition.schema'; -import { TestRunnerService } from '@/evaluation/test-runner/test-runner.service.ee'; +} from '@/evaluation.ee/test-definition.schema'; +import { TestRunnerService } from '@/evaluation.ee/test-runner/test-runner.service.ee'; import { listQueryMiddleware } from '@/middlewares'; import { getSharedWorkflowIds } from '@/public-api/v1/handlers/workflows/workflows.service'; diff --git a/packages/cli/src/evaluation/test-definitions.types.ee.ts b/packages/cli/src/evaluation.ee/test-definitions.types.ee.ts similarity index 100% rename from packages/cli/src/evaluation/test-definitions.types.ee.ts rename to packages/cli/src/evaluation.ee/test-definitions.types.ee.ts diff --git a/packages/cli/src/evaluation/test-runner/__tests__/create-pin-data.ee.test.ts b/packages/cli/src/evaluation.ee/test-runner/__tests__/create-pin-data.ee.test.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/create-pin-data.ee.test.ts rename to packages/cli/src/evaluation.ee/test-runner/__tests__/create-pin-data.ee.test.ts diff --git a/packages/cli/src/evaluation/test-runner/__tests__/evaluation-metrics.ee.test.ts b/packages/cli/src/evaluation.ee/test-runner/__tests__/evaluation-metrics.ee.test.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/evaluation-metrics.ee.test.ts rename to packages/cli/src/evaluation.ee/test-runner/__tests__/evaluation-metrics.ee.test.ts diff --git a/packages/cli/src/evaluation/test-runner/__tests__/get-start-node.ee.test.ts b/packages/cli/src/evaluation.ee/test-runner/__tests__/get-start-node.ee.test.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/get-start-node.ee.test.ts rename to packages/cli/src/evaluation.ee/test-runner/__tests__/get-start-node.ee.test.ts diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.evaluation.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.evaluation.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.multiple-triggers.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.multiple-triggers.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.multiple-triggers.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.multiple-triggers.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.under-test.json b/packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.under-test.json similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.under-test.json rename to packages/cli/src/evaluation.ee/test-runner/__tests__/mock-data/workflow.under-test.json diff --git a/packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts b/packages/cli/src/evaluation.ee/test-runner/__tests__/test-runner.service.ee.test.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts rename to packages/cli/src/evaluation.ee/test-runner/__tests__/test-runner.service.ee.test.ts diff --git a/packages/cli/src/evaluation/test-runner/evaluation-metrics.ee.ts b/packages/cli/src/evaluation.ee/test-runner/evaluation-metrics.ee.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/evaluation-metrics.ee.ts rename to packages/cli/src/evaluation.ee/test-runner/evaluation-metrics.ee.ts diff --git a/packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts b/packages/cli/src/evaluation.ee/test-runner/test-runner.service.ee.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts rename to packages/cli/src/evaluation.ee/test-runner/test-runner.service.ee.ts diff --git a/packages/cli/src/evaluation/test-runner/utils.ee.ts b/packages/cli/src/evaluation.ee/test-runner/utils.ee.ts similarity index 100% rename from packages/cli/src/evaluation/test-runner/utils.ee.ts rename to packages/cli/src/evaluation.ee/test-runner/utils.ee.ts diff --git a/packages/cli/src/evaluation/test-runs.controller.ee.ts b/packages/cli/src/evaluation.ee/test-runs.controller.ee.ts similarity index 96% rename from packages/cli/src/evaluation/test-runs.controller.ee.ts rename to packages/cli/src/evaluation.ee/test-runs.controller.ee.ts index 744c420fc0d9a..aae71376e4857 100644 --- a/packages/cli/src/evaluation/test-runs.controller.ee.ts +++ b/packages/cli/src/evaluation.ee/test-runs.controller.ee.ts @@ -1,7 +1,7 @@ import { TestRunRepository } from '@/databases/repositories/test-run.repository.ee'; import { Delete, Get, RestController } from '@/decorators'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { TestRunsRequest } from '@/evaluation/test-definitions.types.ee'; +import { TestRunsRequest } from '@/evaluation.ee/test-definitions.types.ee'; import { listQueryMiddleware } from '@/middlewares'; import { getSharedWorkflowIds } from '@/public-api/v1/handlers/workflows/workflows.service'; diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts index a5373d0cc5cd1..8bc967e789266 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts @@ -14,7 +14,7 @@ import type { import Container from 'typedi'; import { CredentialsHelper } from '@/credentials-helper'; -import * as SecretsHelpers from '@/external-secrets/external-secrets-helper.ee'; +import * as SecretsHelpers from '@/external-secrets.ee/external-secrets-helper.ee'; import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; diff --git a/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts b/packages/cli/src/external-secrets.ee/__tests__/external-secrets-manager.ee.test.ts similarity index 95% rename from packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts rename to packages/cli/src/external-secrets.ee/__tests__/external-secrets-manager.ee.test.ts index 05eabd104fa52..341558a5fe00f 100644 --- a/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts +++ b/packages/cli/src/external-secrets.ee/__tests__/external-secrets-manager.ee.test.ts @@ -3,8 +3,8 @@ import { Cipher } from 'n8n-core'; import { Container } from 'typedi'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; -import { ExternalSecretsProviders } from '@/external-secrets/external-secrets-providers.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; +import { ExternalSecretsProviders } from '@/external-secrets.ee/external-secrets-providers.ee'; import type { ExternalSecretsSettings } from '@/interfaces'; import { License } from '@/license'; import { diff --git a/packages/cli/src/external-secrets/constants.ts b/packages/cli/src/external-secrets.ee/constants.ts similarity index 100% rename from packages/cli/src/external-secrets/constants.ts rename to packages/cli/src/external-secrets.ee/constants.ts diff --git a/packages/cli/src/external-secrets/external-secrets-helper.ee.ts b/packages/cli/src/external-secrets.ee/external-secrets-helper.ee.ts similarity index 100% rename from packages/cli/src/external-secrets/external-secrets-helper.ee.ts rename to packages/cli/src/external-secrets.ee/external-secrets-helper.ee.ts diff --git a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts b/packages/cli/src/external-secrets.ee/external-secrets-manager.ee.ts similarity index 100% rename from packages/cli/src/external-secrets/external-secrets-manager.ee.ts rename to packages/cli/src/external-secrets.ee/external-secrets-manager.ee.ts diff --git a/packages/cli/src/external-secrets/external-secrets-providers.ee.ts b/packages/cli/src/external-secrets.ee/external-secrets-providers.ee.ts similarity index 100% rename from packages/cli/src/external-secrets/external-secrets-providers.ee.ts rename to packages/cli/src/external-secrets.ee/external-secrets-providers.ee.ts diff --git a/packages/cli/src/external-secrets/external-secrets.controller.ee.ts b/packages/cli/src/external-secrets.ee/external-secrets.controller.ee.ts similarity index 100% rename from packages/cli/src/external-secrets/external-secrets.controller.ee.ts rename to packages/cli/src/external-secrets.ee/external-secrets.controller.ee.ts diff --git a/packages/cli/src/external-secrets/external-secrets.service.ee.ts b/packages/cli/src/external-secrets.ee/external-secrets.service.ee.ts similarity index 100% rename from packages/cli/src/external-secrets/external-secrets.service.ee.ts rename to packages/cli/src/external-secrets.ee/external-secrets.service.ee.ts diff --git a/packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts b/packages/cli/src/external-secrets.ee/providers/__tests__/azure-key-vault.test.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts rename to packages/cli/src/external-secrets.ee/providers/__tests__/azure-key-vault.test.ts diff --git a/packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts b/packages/cli/src/external-secrets.ee/providers/__tests__/gcp-secrets-manager.test.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts rename to packages/cli/src/external-secrets.ee/providers/__tests__/gcp-secrets-manager.test.ts diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts b/packages/cli/src/external-secrets.ee/providers/aws-secrets/aws-secrets-client.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts rename to packages/cli/src/external-secrets.ee/providers/aws-secrets/aws-secrets-client.ts diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts b/packages/cli/src/external-secrets.ee/providers/aws-secrets/aws-secrets-manager.ts similarity index 99% rename from packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts rename to packages/cli/src/external-secrets.ee/providers/aws-secrets/aws-secrets-manager.ts index 629b3ad626bc2..b22c2f24364a4 100644 --- a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts +++ b/packages/cli/src/external-secrets.ee/providers/aws-secrets/aws-secrets-manager.ts @@ -3,7 +3,7 @@ import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { UnknownAuthTypeError } from '@/errors/unknown-auth-type.error'; -import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; +import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets.ee/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; import { AwsSecretsClient } from './aws-secrets-client'; diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/types.ts b/packages/cli/src/external-secrets.ee/providers/aws-secrets/types.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/aws-secrets/types.ts rename to packages/cli/src/external-secrets.ee/providers/aws-secrets/types.ts diff --git a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts b/packages/cli/src/external-secrets.ee/providers/azure-key-vault/azure-key-vault.ts similarity index 99% rename from packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts rename to packages/cli/src/external-secrets.ee/providers/azure-key-vault/azure-key-vault.ts index 01995d699012b..a03ef468b6b04 100644 --- a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts +++ b/packages/cli/src/external-secrets.ee/providers/azure-key-vault/azure-key-vault.ts @@ -4,7 +4,7 @@ import { ensureError } from 'n8n-workflow'; import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; -import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; +import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets.ee/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; import type { AzureKeyVaultContext } from './types'; diff --git a/packages/cli/src/external-secrets/providers/azure-key-vault/types.ts b/packages/cli/src/external-secrets.ee/providers/azure-key-vault/types.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/azure-key-vault/types.ts rename to packages/cli/src/external-secrets.ee/providers/azure-key-vault/types.ts diff --git a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts b/packages/cli/src/external-secrets.ee/providers/gcp-secrets-manager/gcp-secrets-manager.ts similarity index 99% rename from packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts rename to packages/cli/src/external-secrets.ee/providers/gcp-secrets-manager/gcp-secrets-manager.ts index ec29a281984c0..fe039fd50ae6f 100644 --- a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts +++ b/packages/cli/src/external-secrets.ee/providers/gcp-secrets-manager/gcp-secrets-manager.ts @@ -3,7 +3,7 @@ import { Logger } from 'n8n-core'; import { ensureError, jsonParse, type INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; -import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; +import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets.ee/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; import type { diff --git a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/types.ts b/packages/cli/src/external-secrets.ee/providers/gcp-secrets-manager/types.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/gcp-secrets-manager/types.ts rename to packages/cli/src/external-secrets.ee/providers/gcp-secrets-manager/types.ts diff --git a/packages/cli/src/external-secrets/providers/infisical.ts b/packages/cli/src/external-secrets.ee/providers/infisical.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/infisical.ts rename to packages/cli/src/external-secrets.ee/providers/infisical.ts diff --git a/packages/cli/src/external-secrets/providers/vault.ts b/packages/cli/src/external-secrets.ee/providers/vault.ts similarity index 100% rename from packages/cli/src/external-secrets/providers/vault.ts rename to packages/cli/src/external-secrets.ee/providers/vault.ts diff --git a/packages/cli/src/ldap/__tests__/helpers.test.ts b/packages/cli/src/ldap.ee/__tests__/helpers.test.ts similarity index 96% rename from packages/cli/src/ldap/__tests__/helpers.test.ts rename to packages/cli/src/ldap.ee/__tests__/helpers.test.ts index 5d38c58e1a521..3e7a9c4b4b72a 100644 --- a/packages/cli/src/ldap/__tests__/helpers.test.ts +++ b/packages/cli/src/ldap.ee/__tests__/helpers.test.ts @@ -2,7 +2,7 @@ import { AuthIdentity } from '@/databases/entities/auth-identity'; import { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; import { generateNanoId } from '@/databases/utils/generators'; -import * as helpers from '@/ldap/helpers.ee'; +import * as helpers from '@/ldap.ee/helpers.ee'; import { mockInstance } from '@test/mocking'; const userRepository = mockInstance(UserRepository); diff --git a/packages/cli/src/ldap/constants.ts b/packages/cli/src/ldap.ee/constants.ts similarity index 100% rename from packages/cli/src/ldap/constants.ts rename to packages/cli/src/ldap.ee/constants.ts diff --git a/packages/cli/src/ldap/helpers.ee.ts b/packages/cli/src/ldap.ee/helpers.ee.ts similarity index 100% rename from packages/cli/src/ldap/helpers.ee.ts rename to packages/cli/src/ldap.ee/helpers.ee.ts diff --git a/packages/cli/src/ldap/ldap.controller.ee.ts b/packages/cli/src/ldap.ee/ldap.controller.ee.ts similarity index 100% rename from packages/cli/src/ldap/ldap.controller.ee.ts rename to packages/cli/src/ldap.ee/ldap.controller.ee.ts diff --git a/packages/cli/src/ldap/ldap.service.ee.ts b/packages/cli/src/ldap.ee/ldap.service.ee.ts similarity index 99% rename from packages/cli/src/ldap/ldap.service.ee.ts rename to packages/cli/src/ldap.ee/ldap.service.ee.ts index 1445f56f13c35..9a794bd5fc8f4 100644 --- a/packages/cli/src/ldap/ldap.service.ee.ts +++ b/packages/cli/src/ldap.ee/ldap.service.ee.ts @@ -19,7 +19,7 @@ import { isEmailCurrentAuthenticationMethod, isLdapCurrentAuthenticationMethod, setCurrentAuthenticationMethod, -} from '@/sso/sso-helpers'; +} from '@/sso.ee/sso-helpers'; import { BINARY_AD_ATTRIBUTES, diff --git a/packages/cli/src/ldap/types.ts b/packages/cli/src/ldap.ee/types.ts similarity index 100% rename from packages/cli/src/ldap/types.ts rename to packages/cli/src/ldap.ee/types.ts diff --git a/packages/cli/src/permissions/check-access.ts b/packages/cli/src/permissions.ee/check-access.ts similarity index 100% rename from packages/cli/src/permissions/check-access.ts rename to packages/cli/src/permissions.ee/check-access.ts diff --git a/packages/cli/src/permissions/global-roles.ts b/packages/cli/src/permissions.ee/global-roles.ts similarity index 100% rename from packages/cli/src/permissions/global-roles.ts rename to packages/cli/src/permissions.ee/global-roles.ts diff --git a/packages/cli/src/permissions/project-roles.ts b/packages/cli/src/permissions.ee/project-roles.ts similarity index 100% rename from packages/cli/src/permissions/project-roles.ts rename to packages/cli/src/permissions.ee/project-roles.ts diff --git a/packages/cli/src/permissions/resource-roles.ts b/packages/cli/src/permissions.ee/resource-roles.ts similarity index 100% rename from packages/cli/src/permissions/resource-roles.ts rename to packages/cli/src/permissions.ee/resource-roles.ts diff --git a/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts b/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts index fdcb2f16baabf..6f960980ca715 100644 --- a/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts @@ -5,10 +5,10 @@ import { Container } from 'typedi'; import { getTrackingInformationFromPullResult, isSourceControlLicensed, -} from '@/environments/source-control/source-control-helper.ee'; -import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; -import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; -import type { ImportResult } from '@/environments/source-control/types/import-result'; +} from '@/environments.ee/source-control/source-control-helper.ee'; +import { SourceControlPreferencesService } from '@/environments.ee/source-control/source-control-preferences.service.ee'; +import { SourceControlService } from '@/environments.ee/source-control/source-control.service.ee'; +import type { ImportResult } from '@/environments.ee/source-control/types/import-result'; import { EventService } from '@/events/event.service'; import type { PublicSourceControlRequest } from '../../../types'; diff --git a/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts b/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts index 65fb1daab5653..9e5b6dabe6dee 100644 --- a/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts @@ -2,7 +2,7 @@ import type { Response } from 'express'; import Container from 'typedi'; import { VariablesRepository } from '@/databases/repositories/variables.repository'; -import { VariablesController } from '@/environments/variables/variables.controller.ee'; +import { VariablesController } from '@/environments.ee/variables/variables.controller.ee'; import type { PaginatedRequest } from '@/public-api/types'; import type { VariablesRequest } from '@/requests'; diff --git a/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts b/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts index 7a9003dc284c6..500eaf0d13fa1 100644 --- a/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts @@ -17,7 +17,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { addNodeIds, replaceInvalidCredentials } from '@/workflow-helpers'; -import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; +import { WorkflowHistoryService } from '@/workflows/workflow-history.ee/workflow-history.service.ee'; import { WorkflowService } from '@/workflows/workflow.service'; import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; diff --git a/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts b/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts index ed68d4761c8d4..ace75ef6102fb 100644 --- a/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts +++ b/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts @@ -6,7 +6,7 @@ import { Container } from 'typedi'; import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import type { BooleanLicenseFeature } from '@/interfaces'; import { License } from '@/license'; -import { userHasScopes } from '@/permissions/check-access'; +import { userHasScopes } from '@/permissions.ee/check-access'; import type { AuthenticatedRequest } from '@/requests'; import type { PaginatedRequest } from '../../../types'; diff --git a/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts b/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts index 4f8c8af85956f..b92c18c885712 100644 --- a/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts +++ b/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts @@ -7,7 +7,7 @@ import type { ActiveWorkflowManager } from '@/active-workflow-manager'; import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { EventService } from '@/events/event.service'; -import type { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import type { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; import type { IWorkflowDb } from '@/interfaces'; import type { License } from '@/license'; import type { Push } from '@/push'; @@ -17,7 +17,7 @@ import type { TestWebhooks } from '@/webhooks/test-webhooks'; import type { Publisher } from '../pubsub/publisher.service'; import { PubSubHandler } from '../pubsub/pubsub-handler'; -import type { WorkerStatusService } from '../worker-status.service'; +import type { WorkerStatusService } from '../worker-status.service.ee'; const flushPromises = async () => await new Promise((resolve) => setImmediate(resolve)); diff --git a/packages/cli/src/scaling/pubsub/pubsub-handler.ts b/packages/cli/src/scaling/pubsub/pubsub-handler.ts index 70b5f67f72c37..10a763f8f1db2 100644 --- a/packages/cli/src/scaling/pubsub/pubsub-handler.ts +++ b/packages/cli/src/scaling/pubsub/pubsub-handler.ts @@ -7,7 +7,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { EventService } from '@/events/event.service'; import type { PubSubEventMap } from '@/events/maps/pub-sub.event-map'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; import { License } from '@/license'; import { Push } from '@/push'; import { Publisher } from '@/scaling/pubsub/publisher.service'; @@ -16,7 +16,7 @@ import { assertNever } from '@/utils'; import { TestWebhooks } from '@/webhooks/test-webhooks'; import type { PubSub } from './pubsub.types'; -import { WorkerStatusService } from '../worker-status.service'; +import { WorkerStatusService } from '../worker-status.service.ee'; /** * Responsible for handling events emitted from messages received via a pubsub channel. diff --git a/packages/cli/src/scaling/worker-status.service.ts b/packages/cli/src/scaling/worker-status.service.ee.ts similarity index 100% rename from packages/cli/src/scaling/worker-status.service.ts rename to packages/cli/src/scaling/worker-status.service.ee.ts diff --git a/packages/cli/src/secrets-helpers.ts b/packages/cli/src/secrets-helpers.ee.ts similarity index 90% rename from packages/cli/src/secrets-helpers.ts rename to packages/cli/src/secrets-helpers.ee.ts index 88a75ae3daa07..fdc18c4b85920 100644 --- a/packages/cli/src/secrets-helpers.ts +++ b/packages/cli/src/secrets-helpers.ee.ts @@ -1,7 +1,7 @@ import type { SecretsHelpersBase } from 'n8n-workflow'; import { Service } from 'typedi'; -import { ExternalSecretsManager } from './external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsManager } from './external-secrets.ee/external-secrets-manager.ee'; @Service() export class SecretsHelper implements SecretsHelpersBase { diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.ts index 74a13114448aa..b2b1c3a1c8bcf 100644 --- a/packages/cli/src/server.ts +++ b/packages/cli/src/server.ts @@ -23,7 +23,7 @@ import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus' import { EventService } from '@/events/event.service'; import { LogStreamingEventRelay } from '@/events/relays/log-streaming.event-relay'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { isLdapEnabled } from '@/ldap/helpers.ee'; +import { isLdapEnabled } from '@/ldap.ee/helpers.ee'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { handleMfaDisable, isMfaFeatureEnabled } from '@/mfa/helpers'; import { PostHogClient } from '@/posthog'; @@ -60,12 +60,12 @@ import '@/credentials/credentials.controller'; import '@/eventbus/event-bus.controller'; import '@/events/events.controller'; import '@/executions/executions.controller'; -import '@/external-secrets/external-secrets.controller.ee'; +import '@/external-secrets.ee/external-secrets.controller.ee'; import '@/license/license.controller'; -import '@/evaluation/test-definitions.controller.ee'; -import '@/evaluation/metrics.controller'; -import '@/evaluation/test-runs.controller.ee'; -import '@/workflows/workflow-history/workflow-history.controller.ee'; +import '@/evaluation.ee/test-definitions.controller.ee'; +import '@/evaluation.ee/metrics.controller'; +import '@/evaluation.ee/test-runs.controller.ee'; +import '@/workflows/workflow-history.ee/workflow-history.controller.ee'; import '@/workflows/workflows.controller'; @Service() @@ -114,8 +114,8 @@ export class Server extends AbstractServer { } if (isLdapEnabled()) { - const { LdapService } = await import('@/ldap/ldap.service.ee'); - await import('@/ldap/ldap.controller.ee'); + const { LdapService } = await import('@/ldap.ee/ldap.service.ee'); + await import('@/ldap.ee/ldap.controller.ee'); await Container.get(LdapService).init(); } @@ -142,9 +142,9 @@ export class Server extends AbstractServer { // initialize SamlService if it is licensed, even if not enabled, to // set up the initial environment try { - const { SamlService } = await import('@/sso/saml/saml.service.ee'); + const { SamlService } = await import('@/sso.ee/saml/saml.service.ee'); await Container.get(SamlService).init(); - await import('@/sso/saml/routes/saml.controller.ee'); + await import('@/sso.ee/saml/routes/saml.controller.ee'); } catch (error) { this.logger.warn(`SAML initialization failed: ${(error as Error).message}`); } @@ -154,11 +154,11 @@ export class Server extends AbstractServer { // ---------------------------------------- try { const { SourceControlService } = await import( - '@/environments/source-control/source-control.service.ee' + '@/environments.ee/source-control/source-control.service.ee' ); await Container.get(SourceControlService).init(); - await import('@/environments/source-control/source-control.controller.ee'); - await import('@/environments/variables/variables.controller.ee'); + await import('@/environments.ee/source-control/source-control.controller.ee'); + await import('@/environments.ee/variables/variables.controller.ee'); } catch (error) { this.logger.warn(`Source Control initialization failed: ${(error as Error).message}`); } diff --git a/packages/cli/src/services/__tests__/orchestration.service.test.ts b/packages/cli/src/services/__tests__/orchestration.service.test.ts index a8e72c49bf64b..45e79036ac0d3 100644 --- a/packages/cli/src/services/__tests__/orchestration.service.test.ts +++ b/packages/cli/src/services/__tests__/orchestration.service.test.ts @@ -5,7 +5,7 @@ import Container from 'typedi'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; import { Push } from '@/push'; import { OrchestrationService } from '@/services/orchestration.service'; import { RedisClientService } from '@/services/redis-client.service'; diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index 75fe36358faf3..ae7a596005599 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -12,19 +12,19 @@ import config from '@/config'; import { inE2ETests, LICENSE_FEATURES, N8N_VERSION } from '@/constants'; import { CredentialTypes } from '@/credential-types'; import { CredentialsOverwrites } from '@/credentials-overwrites'; -import { getVariablesLimit } from '@/environments/variables/environment-helpers'; -import { getLdapLoginLabel } from '@/ldap/helpers.ee'; +import { getVariablesLimit } from '@/environments.ee/variables/environment-helpers'; +import { getLdapLoginLabel } from '@/ldap.ee/helpers.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { isApiEnabled } from '@/public-api'; import type { CommunityPackagesService } from '@/services/community-packages.service'; -import { getSamlLoginLabel } from '@/sso/saml/saml-helpers'; -import { getCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { getSamlLoginLabel } from '@/sso.ee/saml/saml-helpers'; +import { getCurrentAuthenticationMethod } from '@/sso.ee/sso-helpers'; import { UserManagementMailer } from '@/user-management/email'; import { getWorkflowHistoryLicensePruneTime, getWorkflowHistoryPruneTime, -} from '@/workflows/workflow-history/workflow-history-helper.ee'; +} from '@/workflows/workflow-history.ee/workflow-history-helper.ee'; import { UrlService } from './url.service'; diff --git a/packages/cli/src/services/project.service.ts b/packages/cli/src/services/project.service.ee.ts similarity index 100% rename from packages/cli/src/services/project.service.ts rename to packages/cli/src/services/project.service.ee.ts diff --git a/packages/cli/src/services/role.service.ts b/packages/cli/src/services/role.service.ts index 97adbbfb7d908..a4fd5daee1d09 100644 --- a/packages/cli/src/services/role.service.ts +++ b/packages/cli/src/services/role.service.ts @@ -15,19 +15,19 @@ import { GLOBAL_ADMIN_SCOPES, GLOBAL_MEMBER_SCOPES, GLOBAL_OWNER_SCOPES, -} from '@/permissions/global-roles'; +} from '@/permissions.ee/global-roles'; import { PERSONAL_PROJECT_OWNER_SCOPES, PROJECT_EDITOR_SCOPES, PROJECT_VIEWER_SCOPES, REGULAR_PROJECT_ADMIN_SCOPES, -} from '@/permissions/project-roles'; +} from '@/permissions.ee/project-roles'; import { CREDENTIALS_SHARING_OWNER_SCOPES, CREDENTIALS_SHARING_USER_SCOPES, WORKFLOW_SHARING_EDITOR_SCOPES, WORKFLOW_SHARING_OWNER_SCOPES, -} from '@/permissions/resource-roles'; +} from '@/permissions.ee/resource-roles'; import type { ListQuery } from '@/requests'; export type RoleNamespace = 'global' | 'project' | 'credential' | 'workflow'; diff --git a/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts b/packages/cli/src/sso.ee/saml/__tests__/saml-helpers.test.ts similarity index 92% rename from packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts rename to packages/cli/src/sso.ee/saml/__tests__/saml-helpers.test.ts index 76ae2e4d50500..f544e050ed23c 100644 --- a/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts +++ b/packages/cli/src/sso.ee/saml/__tests__/saml-helpers.test.ts @@ -3,8 +3,8 @@ import { User } from '@/databases/entities/user'; import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; import { generateNanoId } from '@/databases/utils/generators'; -import * as helpers from '@/sso/saml/saml-helpers'; -import type { SamlUserAttributes } from '@/sso/saml/types/saml-user-attributes'; +import * as helpers from '@/sso.ee/saml/saml-helpers'; +import type { SamlUserAttributes } from '@/sso.ee/saml/types/saml-user-attributes'; import { mockInstance } from '@test/mocking'; const userRepository = mockInstance(UserRepository); diff --git a/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts b/packages/cli/src/sso.ee/saml/__tests__/saml-validator.test.ts similarity index 100% rename from packages/cli/src/sso/saml/__tests__/saml-validator.test.ts rename to packages/cli/src/sso.ee/saml/__tests__/saml-validator.test.ts diff --git a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts b/packages/cli/src/sso.ee/saml/__tests__/saml.service.ee.test.ts similarity index 97% rename from packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts rename to packages/cli/src/sso.ee/saml/__tests__/saml.service.ee.test.ts index 708592e8e7c97..6070104571abc 100644 --- a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts +++ b/packages/cli/src/sso.ee/saml/__tests__/saml.service.ee.test.ts @@ -5,8 +5,8 @@ import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify' import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { UrlService } from '@/services/url.service'; -import * as samlHelpers from '@/sso/saml/saml-helpers'; -import { SamlService } from '@/sso/saml/saml.service.ee'; +import * as samlHelpers from '@/sso.ee/saml/saml-helpers'; +import { SamlService } from '@/sso.ee/saml/saml.service.ee'; import { mockInstance } from '@test/mocking'; import { SAML_PREFERENCES_DB_KEY } from '../constants'; diff --git a/packages/cli/src/sso/saml/constants.ts b/packages/cli/src/sso.ee/saml/constants.ts similarity index 100% rename from packages/cli/src/sso/saml/constants.ts rename to packages/cli/src/sso.ee/saml/constants.ts diff --git a/packages/cli/src/sso/saml/errors/invalid-saml-metadata.error.ts b/packages/cli/src/sso.ee/saml/errors/invalid-saml-metadata.error.ts similarity index 100% rename from packages/cli/src/sso/saml/errors/invalid-saml-metadata.error.ts rename to packages/cli/src/sso.ee/saml/errors/invalid-saml-metadata.error.ts diff --git a/packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts b/packages/cli/src/sso.ee/saml/middleware/saml-enabled-middleware.ts similarity index 100% rename from packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts rename to packages/cli/src/sso.ee/saml/middleware/saml-enabled-middleware.ts diff --git a/packages/cli/src/sso/saml/routes/__tests__/saml.controller.ee.test.ts b/packages/cli/src/sso.ee/saml/routes/__tests__/saml.controller.ee.test.ts similarity index 100% rename from packages/cli/src/sso/saml/routes/__tests__/saml.controller.ee.test.ts rename to packages/cli/src/sso.ee/saml/routes/__tests__/saml.controller.ee.test.ts diff --git a/packages/cli/src/sso/saml/routes/saml.controller.ee.ts b/packages/cli/src/sso.ee/saml/routes/saml.controller.ee.ts similarity index 100% rename from packages/cli/src/sso/saml/routes/saml.controller.ee.ts rename to packages/cli/src/sso.ee/saml/routes/saml.controller.ee.ts diff --git a/packages/cli/src/sso/saml/saml-helpers.ts b/packages/cli/src/sso.ee/saml/saml-helpers.ts similarity index 100% rename from packages/cli/src/sso/saml/saml-helpers.ts rename to packages/cli/src/sso.ee/saml/saml-helpers.ts diff --git a/packages/cli/src/sso/saml/saml-validator.ts b/packages/cli/src/sso.ee/saml/saml-validator.ts similarity index 100% rename from packages/cli/src/sso/saml/saml-validator.ts rename to packages/cli/src/sso.ee/saml/saml-validator.ts diff --git a/packages/cli/src/sso/saml/saml.service.ee.ts b/packages/cli/src/sso.ee/saml/saml.service.ee.ts similarity index 100% rename from packages/cli/src/sso/saml/saml.service.ee.ts rename to packages/cli/src/sso.ee/saml/saml.service.ee.ts diff --git a/packages/cli/src/sso/saml/schema/metadata-exchange.xsd.ts b/packages/cli/src/sso.ee/saml/schema/metadata-exchange.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/metadata-exchange.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/metadata-exchange.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.ts b/packages/cli/src/sso.ee/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.ts b/packages/cli/src/sso.ee/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/saml-schema-assertion-2.0.xsd.ts b/packages/cli/src/sso.ee/saml/schema/saml-schema-assertion-2.0.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/saml-schema-assertion-2.0.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/saml-schema-assertion-2.0.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/saml-schema-metadata-2.0.xsd.ts b/packages/cli/src/sso.ee/saml/schema/saml-schema-metadata-2.0.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/saml-schema-metadata-2.0.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/saml-schema-metadata-2.0.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/saml-schema-protocol-2.0.xsd.ts b/packages/cli/src/sso.ee/saml/schema/saml-schema-protocol-2.0.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/saml-schema-protocol-2.0.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/saml-schema-protocol-2.0.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/ws-addr.xsd.ts b/packages/cli/src/sso.ee/saml/schema/ws-addr.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/ws-addr.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/ws-addr.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/ws-authorization.xsd.ts b/packages/cli/src/sso.ee/saml/schema/ws-authorization.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/ws-authorization.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/ws-authorization.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/ws-federation.xsd.ts b/packages/cli/src/sso.ee/saml/schema/ws-federation.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/ws-federation.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/ws-federation.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/ws-securitypolicy-1.2.xsd.ts b/packages/cli/src/sso.ee/saml/schema/ws-securitypolicy-1.2.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/ws-securitypolicy-1.2.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/ws-securitypolicy-1.2.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/xenc-schema.xsd.ts b/packages/cli/src/sso.ee/saml/schema/xenc-schema.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/xenc-schema.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/xenc-schema.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/xml.xsd.ts b/packages/cli/src/sso.ee/saml/schema/xml.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/xml.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/xml.xsd.ts diff --git a/packages/cli/src/sso/saml/schema/xmldsig-core-schema.xsd.ts b/packages/cli/src/sso.ee/saml/schema/xmldsig-core-schema.xsd.ts similarity index 100% rename from packages/cli/src/sso/saml/schema/xmldsig-core-schema.xsd.ts rename to packages/cli/src/sso.ee/saml/schema/xmldsig-core-schema.xsd.ts diff --git a/packages/cli/src/sso/saml/service-provider.ee.ts b/packages/cli/src/sso.ee/saml/service-provider.ee.ts similarity index 100% rename from packages/cli/src/sso/saml/service-provider.ee.ts rename to packages/cli/src/sso.ee/saml/service-provider.ee.ts diff --git a/packages/cli/src/sso/saml/types/index.ts b/packages/cli/src/sso.ee/saml/types/index.ts similarity index 100% rename from packages/cli/src/sso/saml/types/index.ts rename to packages/cli/src/sso.ee/saml/types/index.ts diff --git a/packages/cli/src/sso/saml/types/requests.ts b/packages/cli/src/sso.ee/saml/types/requests.ts similarity index 100% rename from packages/cli/src/sso/saml/types/requests.ts rename to packages/cli/src/sso.ee/saml/types/requests.ts diff --git a/packages/cli/src/sso/saml/types/saml-attribute-mapping.ts b/packages/cli/src/sso.ee/saml/types/saml-attribute-mapping.ts similarity index 100% rename from packages/cli/src/sso/saml/types/saml-attribute-mapping.ts rename to packages/cli/src/sso.ee/saml/types/saml-attribute-mapping.ts diff --git a/packages/cli/src/sso/saml/types/saml-preferences.ts b/packages/cli/src/sso.ee/saml/types/saml-preferences.ts similarity index 100% rename from packages/cli/src/sso/saml/types/saml-preferences.ts rename to packages/cli/src/sso.ee/saml/types/saml-preferences.ts diff --git a/packages/cli/src/sso/saml/types/saml-user-attributes.ts b/packages/cli/src/sso.ee/saml/types/saml-user-attributes.ts similarity index 100% rename from packages/cli/src/sso/saml/types/saml-user-attributes.ts rename to packages/cli/src/sso.ee/saml/types/saml-user-attributes.ts diff --git a/packages/cli/src/sso/saml/views/init-sso-post.ts b/packages/cli/src/sso.ee/saml/views/init-sso-post.ts similarity index 100% rename from packages/cli/src/sso/saml/views/init-sso-post.ts rename to packages/cli/src/sso.ee/saml/views/init-sso-post.ts diff --git a/packages/cli/src/sso/sso-helpers.ts b/packages/cli/src/sso.ee/sso-helpers.ts similarity index 100% rename from packages/cli/src/sso/sso-helpers.ts rename to packages/cli/src/sso.ee/sso-helpers.ts diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index e8099e32cbf36..051ae4cf258a6 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -15,7 +15,7 @@ import type { IExecutionTrackProperties } from '@/interfaces'; import { License } from '@/license'; import { PostHogClient } from '@/posthog'; -import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; +import { SourceControlPreferencesService } from '../environments.ee/source-control/source-control-preferences.service.ee'; type ExecutionTrackDataKey = 'manual_error' | 'manual_success' | 'prod_error' | 'prod_success'; diff --git a/packages/cli/src/user-management/permission-checker.ts b/packages/cli/src/user-management/permission-checker.ts index c93d2acf91cb4..51a6e8c6a3bc1 100644 --- a/packages/cli/src/user-management/permission-checker.ts +++ b/packages/cli/src/user-management/permission-checker.ts @@ -4,7 +4,7 @@ import { Service } from 'typedi'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { OwnershipService } from '@/services/ownership.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; @Service() export class PermissionChecker { diff --git a/packages/cli/src/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index bf97ce0a3fba7..69395b4ec87b8 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -59,7 +59,7 @@ import { } from './execution-lifecycle-hooks/shared/shared-hook-functions'; import { toSaveSettings } from './execution-lifecycle-hooks/to-save-settings'; import { TaskManager } from './runners/task-managers/task-manager'; -import { SecretsHelper } from './secrets-helpers'; +import { SecretsHelper } from './secrets-helpers.ee'; import { OwnershipService } from './services/ownership.service'; import { UrlService } from './services/url.service'; import { SubworkflowPolicyChecker } from './subworkflows/subworkflow-policy-checker.service'; diff --git a/packages/cli/src/workflow-helpers.ts b/packages/cli/src/workflow-helpers.ts index addae4e290b7e..b49e1ae556478 100644 --- a/packages/cli/src/workflow-helpers.ts +++ b/packages/cli/src/workflow-helpers.ts @@ -14,7 +14,7 @@ import { v4 as uuid } from 'uuid'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { VariablesService } from '@/environments/variables/variables.service.ee'; +import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; export function generateFailedExecutionFromError( mode: WorkflowExecuteMode, diff --git a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts b/packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history-helper.ee.test.ts similarity index 97% rename from packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts rename to packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history-helper.ee.test.ts index ce3927f73066b..70e00d2c6ded5 100644 --- a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts +++ b/packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history-helper.ee.test.ts @@ -1,6 +1,6 @@ import config from '@/config'; import { License } from '@/license'; -import { getWorkflowHistoryPruneTime } from '@/workflows/workflow-history/workflow-history-helper.ee'; +import { getWorkflowHistoryPruneTime } from '@/workflows/workflow-history.ee/workflow-history-helper.ee'; import { mockInstance } from '@test/mocking'; let licensePruneTime = -1; diff --git a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts b/packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history.service.ee.test.ts similarity index 96% rename from packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts rename to packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history.service.ee.test.ts index a2a48587f006b..b80b38eb9e963 100644 --- a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts +++ b/packages/cli/src/workflows/workflow-history.ee/__tests__/workflow-history.service.ee.test.ts @@ -3,7 +3,7 @@ import { mockClear } from 'jest-mock-extended'; import { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; +import { WorkflowHistoryService } from '@/workflows/workflow-history.ee/workflow-history.service.ee'; import { mockInstance, mockLogger } from '@test/mocking'; import { getWorkflow } from '@test-integration/workflow'; @@ -24,7 +24,7 @@ const testUser = Object.assign(new User(), { }); let isWorkflowHistoryEnabled = true; -jest.mock('@/workflows/workflow-history/workflow-history-helper.ee', () => { +jest.mock('@/workflows/workflow-history.ee/workflow-history-helper.ee', () => { return { isWorkflowHistoryEnabled: jest.fn(() => isWorkflowHistoryEnabled), }; diff --git a/packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts b/packages/cli/src/workflows/workflow-history.ee/workflow-history-helper.ee.ts similarity index 100% rename from packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts rename to packages/cli/src/workflows/workflow-history.ee/workflow-history-helper.ee.ts diff --git a/packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts b/packages/cli/src/workflows/workflow-history.ee/workflow-history-manager.ee.ts similarity index 100% rename from packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts rename to packages/cli/src/workflows/workflow-history.ee/workflow-history-manager.ee.ts diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts b/packages/cli/src/workflows/workflow-history.ee/workflow-history.controller.ee.ts similarity index 100% rename from packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts rename to packages/cli/src/workflows/workflow-history.ee/workflow-history.controller.ee.ts diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts b/packages/cli/src/workflows/workflow-history.ee/workflow-history.service.ee.ts similarity index 100% rename from packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts rename to packages/cli/src/workflows/workflow-history.ee/workflow-history.service.ee.ts diff --git a/packages/cli/src/workflows/workflow.service.ee.ts b/packages/cli/src/workflows/workflow.service.ee.ts index debaf85073c43..830a3d2f98331 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -19,7 +19,7 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflow.error'; import { OwnershipService } from '@/services/ownership.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import type { WorkflowWithSharingsAndCredentials, diff --git a/packages/cli/src/workflows/workflow.service.ts b/packages/cli/src/workflows/workflow.service.ts index facd372656d9e..21f792747e290 100644 --- a/packages/cli/src/workflows/workflow.service.ts +++ b/packages/cli/src/workflows/workflow.service.ts @@ -27,12 +27,12 @@ import { validateEntity } from '@/generic-helpers'; import { hasSharing, type ListQuery } from '@/requests'; import { OrchestrationService } from '@/services/orchestration.service'; import { OwnershipService } from '@/services/ownership.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { RoleService } from '@/services/role.service'; import { TagService } from '@/services/tag.service'; import * as WorkflowHelpers from '@/workflow-helpers'; -import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; +import { WorkflowHistoryService } from './workflow-history.ee/workflow-history.service.ee'; import { WorkflowSharingService } from './workflow-sharing.service'; @Service() diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index f097b3cab61f9..b12dfdce5a4fe 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -31,14 +31,14 @@ import { License } from '@/license'; import { listQueryMiddleware } from '@/middlewares'; import * as ResponseHelper from '@/response-helper'; import { NamingService } from '@/services/naming.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { TagService } from '@/services/tag.service'; import { UserManagementMailer } from '@/user-management/email'; import * as utils from '@/utils'; import * as WorkflowHelpers from '@/workflow-helpers'; import { WorkflowExecutionService } from './workflow-execution.service'; -import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; +import { WorkflowHistoryService } from './workflow-history.ee/workflow-history.service.ee'; import { WorkflowRequest } from './workflow.request'; import { WorkflowService } from './workflow.service'; import { EnterpriseWorkflowService } from './workflow.service.ee'; diff --git a/packages/cli/test/integration/active-workflow-manager.test.ts b/packages/cli/test/integration/active-workflow-manager.test.ts index f724d156a8277..f965efe709f62 100644 --- a/packages/cli/test/integration/active-workflow-manager.test.ts +++ b/packages/cli/test/integration/active-workflow-manager.test.ts @@ -12,7 +12,7 @@ import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; -import { SecretsHelper } from '@/secrets-helpers'; +import { SecretsHelper } from '@/secrets-helpers.ee'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import { WebhookService } from '@/webhooks/webhook.service'; import * as AdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/test/integration/commands/ldap/reset.test.ts b/packages/cli/test/integration/commands/ldap/reset.test.ts index ef0ab2c0d6e60..a199310f9c652 100644 --- a/packages/cli/test/integration/commands/ldap/reset.test.ts +++ b/packages/cli/test/integration/commands/ldap/reset.test.ts @@ -7,8 +7,8 @@ import { CredentialsRepository } from '@/databases/repositories/credentials.repo import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { getLdapSynchronizations, saveLdapSynchronization } from '@/ldap/helpers.ee'; -import { LdapService } from '@/ldap/ldap.service.ee'; +import { getLdapSynchronizations, saveLdapSynchronization } from '@/ldap.ee/helpers.ee'; +import { LdapService } from '@/ldap.ee/ldap.service.ee'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { Push } from '@/push'; import { Telemetry } from '@/telemetry'; diff --git a/packages/cli/test/integration/commands/worker.cmd.test.ts b/packages/cli/test/integration/commands/worker.cmd.test.ts index e17a8d2279165..f91c001e08daa 100644 --- a/packages/cli/test/integration/commands/worker.cmd.test.ts +++ b/packages/cli/test/integration/commands/worker.cmd.test.ts @@ -9,7 +9,7 @@ import config from '@/config'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { LogStreamingEventRelay } from '@/events/relays/log-streaming.event-relay'; import { ExternalHooks } from '@/external-hooks'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { Push } from '@/push'; diff --git a/packages/cli/test/integration/credentials/credentials.api.ee.test.ts b/packages/cli/test/integration/credentials/credentials.api.ee.test.ts index 5428cafbd4dd2..1606de934d6f3 100644 --- a/packages/cli/test/integration/credentials/credentials.api.ee.test.ts +++ b/packages/cli/test/integration/credentials/credentials.api.ee.test.ts @@ -8,7 +8,7 @@ import type { User } from '@/databases/entities/user'; import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import type { ListQuery } from '@/requests'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { UserManagementMailer } from '@/user-management/email'; import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows'; diff --git a/packages/cli/test/integration/environments/source-control-import.service.test.ts b/packages/cli/test/integration/environments/source-control-import.service.test.ts index 4d2a3d668a6e6..3faa84b6759c5 100644 --- a/packages/cli/test/integration/environments/source-control-import.service.test.ts +++ b/packages/cli/test/integration/environments/source-control-import.service.test.ts @@ -9,9 +9,9 @@ import Container from 'typedi'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { SourceControlImportService } from '@/environments/source-control/source-control-import.service.ee'; -import type { ExportableCredential } from '@/environments/source-control/types/exportable-credential'; -import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +import { SourceControlImportService } from '@/environments.ee/source-control/source-control-import.service.ee'; +import type { ExportableCredential } from '@/environments.ee/source-control/types/exportable-credential'; +import type { SourceControlledFile } from '@/environments.ee/source-control/types/source-controlled-file'; import { mockInstance } from '../../shared/mocking'; import { saveCredential } from '../shared/db/credentials'; diff --git a/packages/cli/test/integration/environments/source-control.test.ts b/packages/cli/test/integration/environments/source-control.test.ts index f983b899aaf76..7e474e1f9adb6 100644 --- a/packages/cli/test/integration/environments/source-control.test.ts +++ b/packages/cli/test/integration/environments/source-control.test.ts @@ -2,9 +2,9 @@ import { Container } from 'typedi'; import config from '@/config'; import type { User } from '@/databases/entities/user'; -import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; -import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; -import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +import { SourceControlPreferencesService } from '@/environments.ee/source-control/source-control-preferences.service.ee'; +import { SourceControlService } from '@/environments.ee/source-control/source-control.service.ee'; +import type { SourceControlledFile } from '@/environments.ee/source-control/types/source-controlled-file'; import { Telemetry } from '@/telemetry'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/test/integration/evaluation/test-definitions.api.test.ts b/packages/cli/test/integration/evaluation/test-definitions.api.test.ts index fe977fbfd3e98..8dd778289d638 100644 --- a/packages/cli/test/integration/evaluation/test-definitions.api.test.ts +++ b/packages/cli/test/integration/evaluation/test-definitions.api.test.ts @@ -5,7 +5,7 @@ import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-en import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { TestDefinitionRepository } from '@/databases/repositories/test-definition.repository.ee'; -import { TestRunnerService } from '@/evaluation/test-runner/test-runner.service.ee'; +import { TestRunnerService } from '@/evaluation.ee/test-runner/test-runner.service.ee'; import { createAnnotationTags } from '@test-integration/db/executions'; import { createUserShell } from './../shared/db/users'; diff --git a/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts b/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts index c36340108ec8c..7e01941c80329 100644 --- a/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts +++ b/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts @@ -7,8 +7,8 @@ import config from '@/config'; import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { EventService } from '@/events/event.service'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; -import { ExternalSecretsProviders } from '@/external-secrets/external-secrets-providers.ee'; +import { ExternalSecretsManager } from '@/external-secrets.ee/external-secrets-manager.ee'; +import { ExternalSecretsProviders } from '@/external-secrets.ee/external-secrets-providers.ee'; import type { ExternalSecretsSettings, SecretsProviderState } from '@/interfaces'; import { License } from '@/license'; diff --git a/packages/cli/test/integration/ldap/ldap.api.test.ts b/packages/cli/test/integration/ldap/ldap.api.test.ts index 17573f49f59bb..884f72315ceb4 100644 --- a/packages/cli/test/integration/ldap/ldap.api.test.ts +++ b/packages/cli/test/integration/ldap/ldap.api.test.ts @@ -7,10 +7,13 @@ import config from '@/config'; import type { User } from '@/databases/entities/user'; import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { LDAP_DEFAULT_CONFIGURATION } from '@/ldap/constants'; -import { saveLdapSynchronization } from '@/ldap/helpers.ee'; -import { LdapService } from '@/ldap/ldap.service.ee'; -import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { LDAP_DEFAULT_CONFIGURATION } from '@/ldap.ee/constants'; +import { saveLdapSynchronization } from '@/ldap.ee/helpers.ee'; +import { LdapService } from '@/ldap.ee/ldap.service.ee'; +import { + getCurrentAuthenticationMethod, + setCurrentAuthenticationMethod, +} from '@/sso.ee/sso-helpers'; import { randomEmail, randomName, uniqueId } from './../shared/random'; import { getPersonalProject } from '../shared/db/projects'; diff --git a/packages/cli/test/integration/password-reset.api.test.ts b/packages/cli/test/integration/password-reset.api.test.ts index 89d66c3f21b6e..2be4c0f0308f6 100644 --- a/packages/cli/test/integration/password-reset.api.test.ts +++ b/packages/cli/test/integration/password-reset.api.test.ts @@ -12,7 +12,7 @@ import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; import { JwtService } from '@/services/jwt.service'; import { PasswordUtility } from '@/services/password.utility'; -import { setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { setCurrentAuthenticationMethod } from '@/sso.ee/sso-helpers'; import { UserManagementMailer } from '@/user-management/email'; import { createUser } from './shared/db/users'; diff --git a/packages/cli/test/integration/project.service.integration.test.ts b/packages/cli/test/integration/project.service.integration.test.ts index 5d425d17eeffc..4c4ad6be5d479 100644 --- a/packages/cli/test/integration/project.service.integration.test.ts +++ b/packages/cli/test/integration/project.service.integration.test.ts @@ -1,7 +1,7 @@ import Container from 'typedi'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { linkUserToProject, createTeamProject } from './shared/db/projects'; import { createUser } from './shared/db/users'; diff --git a/packages/cli/test/integration/public-api/workflows.test.ts b/packages/cli/test/integration/public-api/workflows.test.ts index 28f9d444daa27..51da846b5b03a 100644 --- a/packages/cli/test/integration/public-api/workflows.test.ts +++ b/packages/cli/test/integration/public-api/workflows.test.ts @@ -11,7 +11,7 @@ import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { ExecutionService } from '@/executions/execution.service'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { Telemetry } from '@/telemetry'; import { createTeamProject } from '@test-integration/db/projects'; diff --git a/packages/cli/test/integration/saml/saml-helpers.test.ts b/packages/cli/test/integration/saml/saml-helpers.test.ts index 6ac48ee93b646..3396c0edc72e5 100644 --- a/packages/cli/test/integration/saml/saml-helpers.test.ts +++ b/packages/cli/test/integration/saml/saml-helpers.test.ts @@ -1,5 +1,5 @@ -import * as helpers from '@/sso/saml/saml-helpers'; -import type { SamlUserAttributes } from '@/sso/saml/types/saml-user-attributes'; +import * as helpers from '@/sso.ee/saml/saml-helpers'; +import type { SamlUserAttributes } from '@/sso.ee/saml/types/saml-user-attributes'; import { getPersonalProject } from '../shared/db/projects'; import * as testDb from '../shared/test-db'; diff --git a/packages/cli/test/integration/saml/saml.api.test.ts b/packages/cli/test/integration/saml/saml.api.test.ts index d30d57356a980..247faaacba8ef 100644 --- a/packages/cli/test/integration/saml/saml.api.test.ts +++ b/packages/cli/test/integration/saml/saml.api.test.ts @@ -1,6 +1,9 @@ import type { User } from '@/databases/entities/user'; -import { setSamlLoginEnabled } from '@/sso/saml/saml-helpers'; -import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { setSamlLoginEnabled } from '@/sso.ee/saml/saml-helpers'; +import { + getCurrentAuthenticationMethod, + setCurrentAuthenticationMethod, +} from '@/sso.ee/sso-helpers'; import { sampleConfig } from './sample-metadata'; import { createOwner, createUser } from '../shared/db/users'; diff --git a/packages/cli/test/integration/services/project.service.test.ts b/packages/cli/test/integration/services/project.service.test.ts index 85393a4013278..b475bc83ebdd8 100644 --- a/packages/cli/test/integration/services/project.service.test.ts +++ b/packages/cli/test/integration/services/project.service.test.ts @@ -4,7 +4,7 @@ import Container from 'typedi'; import type { ProjectRole } from '@/databases/entities/project-relation'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { createMember } from '../shared/db/users'; import * as testDb from '../shared/test-db'; diff --git a/packages/cli/test/integration/shared/ldap.ts b/packages/cli/test/integration/shared/ldap.ts index 3f48cf2e3cfc5..9f87bd9962034 100644 --- a/packages/cli/test/integration/shared/ldap.ts +++ b/packages/cli/test/integration/shared/ldap.ts @@ -2,8 +2,8 @@ import { jsonParse } from 'n8n-workflow'; import Container from 'typedi'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; -import type { LdapConfig } from '@/ldap/types'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap.ee/constants'; +import type { LdapConfig } from '@/ldap.ee/types'; export const defaultLdapConfig = { ...LDAP_DEFAULT_CONFIGURATION, diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index f99e0938546ff..8b633200083b3 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -171,7 +171,7 @@ export const setupTestServer = ({ break; case 'variables': - await import('@/environments/variables/variables.controller.ee'); + await import('@/environments.ee/variables/variables.controller.ee'); break; case 'license': @@ -202,20 +202,20 @@ export const setupTestServer = ({ break; case 'ldap': - const { LdapService } = await import('@/ldap/ldap.service.ee'); - await import('@/ldap/ldap.controller.ee'); + const { LdapService } = await import('@/ldap.ee/ldap.service.ee'); + await import('@/ldap.ee/ldap.controller.ee'); testServer.license.enable('feat:ldap'); await Container.get(LdapService).init(); break; case 'saml': - const { setSamlLoginEnabled } = await import('@/sso/saml/saml-helpers'); - await import('@/sso/saml/routes/saml.controller.ee'); + const { setSamlLoginEnabled } = await import('@/sso.ee/saml/saml-helpers'); + await import('@/sso.ee/saml/routes/saml.controller.ee'); await setSamlLoginEnabled(true); break; case 'sourceControl': - await import('@/environments/source-control/source-control.controller.ee'); + await import('@/environments.ee/source-control/source-control.controller.ee'); break; case 'community-packages': @@ -247,11 +247,11 @@ export const setupTestServer = ({ break; case 'externalSecrets': - await import('@/external-secrets/external-secrets.controller.ee'); + await import('@/external-secrets.ee/external-secrets.controller.ee'); break; case 'workflowHistory': - await import('@/workflows/workflow-history/workflow-history.controller.ee'); + await import('@/workflows/workflow-history.ee/workflow-history.controller.ee'); break; case 'binaryData': @@ -279,9 +279,9 @@ export const setupTestServer = ({ break; case 'evaluation': - await import('@/evaluation/metrics.controller'); - await import('@/evaluation/test-definitions.controller.ee'); - await import('@/evaluation/test-runs.controller.ee'); + await import('@/evaluation.ee/metrics.controller'); + await import('@/evaluation.ee/test-definitions.controller.ee'); + await import('@/evaluation.ee/test-runs.controller.ee'); break; } } diff --git a/packages/cli/test/integration/variables.test.ts b/packages/cli/test/integration/variables.test.ts index 7dd8d00aaedd8..c331da8e9999f 100644 --- a/packages/cli/test/integration/variables.test.ts +++ b/packages/cli/test/integration/variables.test.ts @@ -3,7 +3,7 @@ import { Container } from 'typedi'; import type { Variables } from '@/databases/entities/variables'; import { VariablesRepository } from '@/databases/repositories/variables.repository'; import { generateNanoId } from '@/databases/utils/generators'; -import { VariablesService } from '@/environments/variables/variables.service.ee'; +import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; import { CacheService } from '@/services/cache/cache.service'; import { createOwner, createUser } from './shared/db/users'; diff --git a/packages/cli/test/integration/workflow-history-manager.test.ts b/packages/cli/test/integration/workflow-history-manager.test.ts index 825da9fcbf021..eaf5d7447848d 100644 --- a/packages/cli/test/integration/workflow-history-manager.test.ts +++ b/packages/cli/test/integration/workflow-history-manager.test.ts @@ -5,7 +5,7 @@ import Container from 'typedi'; import config from '@/config'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { License } from '@/license'; -import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; +import { WorkflowHistoryManager } from '@/workflows/workflow-history.ee/workflow-history-manager.ee'; import { createManyWorkflowHistoryItems } from './shared/db/workflow-history'; import { createWorkflow } from './shared/db/workflows'; diff --git a/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts b/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts index 3730d0db6cd11..ab02af5b43a66 100644 --- a/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts +++ b/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts @@ -2,7 +2,7 @@ import Container from 'typedi'; import type { User } from '@/databases/entities/user'; import { License } from '@/license'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; import { createUser } from '../shared/db/users'; diff --git a/packages/cli/test/integration/workflows/workflows.controller.test.ts b/packages/cli/test/integration/workflows/workflows.controller.test.ts index fb28918509e57..d0ee2f3d67fae 100644 --- a/packages/cli/test/integration/workflows/workflows.controller.test.ts +++ b/packages/cli/test/integration/workflows/workflows.controller.test.ts @@ -12,7 +12,7 @@ import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-his import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { License } from '@/license'; import type { ListQuery } from '@/requests'; -import { ProjectService } from '@/services/project.service'; +import { ProjectService } from '@/services/project.service.ee'; import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; import { mockInstance } from '../../shared/mocking'; diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index d145ba0c63615..3789372ef8b07 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -15,7 +15,7 @@ "strict": false, "useUnknownInCatchVariables": false }, - "include": ["src/**/*.ts", "test/**/*.ts", "src/sso/saml/saml-schema-metadata-2.0.xsd"], + "include": ["src/**/*.ts", "test/**/*.ts", "src/sso.ee/saml/saml-schema-metadata-2.0.xsd"], "references": [ { "path": "../workflow/tsconfig.build.json" }, { "path": "../core/tsconfig.build.json" }, From 1d5e891a0d3e08dcb13fc39ddf5cdb2cc854d4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 26 Dec 2024 15:31:19 +0100 Subject: [PATCH 03/43] refactor(core): Update AI-Assistant backend code to use DTOs and injectable config (no-changelog) (#12373) --- .../ai-apply-suggestion-request.dto.test.ts | 36 +++ .../ai/__tests__/ai-ask-request.dto.test.ts | 252 ++++++++++++++++++ .../ai/__tests__/ai-chat-request.dto.test.ts | 34 +++ .../dto/ai/ai-apply-suggestion-request.dto.ts | 7 + .../src/dto/ai/ai-ask-request.dto.ts | 53 ++++ .../src/dto/ai/ai-chat-request.dto.ts | 10 + packages/@n8n/api-types/src/dto/index.ts | 3 + .../config/src/configs/aiAssistant.config.ts | 8 + packages/@n8n/config/src/index.ts | 4 + packages/@n8n/config/test/config.test.ts | 3 + packages/cli/src/config/schema.ts | 9 - .../__tests__/ai.controller.test.ts | 111 ++++++++ packages/cli/src/controllers/ai.controller.ts | 27 +- packages/cli/src/requests.ts | 13 - .../src/services/__tests__/ai.service.test.ts | 132 +++++++++ packages/cli/src/services/ai.service.ts | 17 +- 16 files changed, 679 insertions(+), 40 deletions(-) create mode 100644 packages/@n8n/api-types/src/dto/ai/__tests__/ai-apply-suggestion-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/ai/__tests__/ai-ask-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/ai/__tests__/ai-chat-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/ai/ai-apply-suggestion-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/ai/ai-ask-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/ai/ai-chat-request.dto.ts create mode 100644 packages/@n8n/config/src/configs/aiAssistant.config.ts create mode 100644 packages/cli/src/controllers/__tests__/ai.controller.test.ts create mode 100644 packages/cli/src/services/__tests__/ai.service.test.ts diff --git a/packages/@n8n/api-types/src/dto/ai/__tests__/ai-apply-suggestion-request.dto.test.ts b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-apply-suggestion-request.dto.test.ts new file mode 100644 index 0000000000000..568900e409f7f --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-apply-suggestion-request.dto.test.ts @@ -0,0 +1,36 @@ +import { AiApplySuggestionRequestDto } from '../ai-apply-suggestion-request.dto'; + +describe('AiApplySuggestionRequestDto', () => { + it('should validate a valid suggestion application request', () => { + const validRequest = { + sessionId: 'session-123', + suggestionId: 'suggestion-456', + }; + + const result = AiApplySuggestionRequestDto.safeParse(validRequest); + + expect(result.success).toBe(true); + }); + + it('should fail if sessionId is missing', () => { + const invalidRequest = { + suggestionId: 'suggestion-456', + }; + + const result = AiApplySuggestionRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + expect(result.error?.issues[0].path).toEqual(['sessionId']); + }); + + it('should fail if suggestionId is missing', () => { + const invalidRequest = { + sessionId: 'session-123', + }; + + const result = AiApplySuggestionRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + expect(result.error?.issues[0].path).toEqual(['suggestionId']); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/ai/__tests__/ai-ask-request.dto.test.ts b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-ask-request.dto.test.ts new file mode 100644 index 0000000000000..a87eb5f3a4c81 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-ask-request.dto.test.ts @@ -0,0 +1,252 @@ +import { AiAskRequestDto } from '../ai-ask-request.dto'; + +describe('AiAskRequestDto', () => { + const validRequest = { + question: 'How can I improve this workflow?', + context: { + schema: [ + { + nodeName: 'TestNode', + schema: { + type: 'string', + key: 'testKey', + value: 'testValue', + path: '/test/path', + }, + }, + ], + inputSchema: { + nodeName: 'InputNode', + schema: { + type: 'object', + key: 'inputKey', + value: [ + { + type: 'string', + key: 'nestedKey', + value: 'nestedValue', + path: '/nested/path', + }, + ], + path: '/input/path', + }, + }, + pushRef: 'push-123', + ndvPushRef: 'ndv-push-456', + }, + forNode: 'TestWorkflowNode', + }; + + it('should validate a valid AI ask request', () => { + const result = AiAskRequestDto.safeParse(validRequest); + + expect(result.success).toBe(true); + }); + + it('should fail if question is missing', () => { + const invalidRequest = { + ...validRequest, + question: undefined, + }; + + const result = AiAskRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + expect(result.error?.issues[0].path).toEqual(['question']); + }); + + it('should fail if context is invalid', () => { + const invalidRequest = { + ...validRequest, + context: { + ...validRequest.context, + schema: [ + { + nodeName: 'TestNode', + schema: { + type: 'invalid-type', // Invalid type + value: 'testValue', + path: '/test/path', + }, + }, + ], + }, + }; + + const result = AiAskRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + }); + + it('should fail if forNode is missing', () => { + const invalidRequest = { + ...validRequest, + forNode: undefined, + }; + + const result = AiAskRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + expect(result.error?.issues[0].path).toEqual(['forNode']); + }); + + it('should validate all possible schema types', () => { + const allTypesRequest = { + question: 'Test all possible types', + context: { + schema: [ + { + nodeName: 'AllTypesNode', + schema: { + type: 'object', + key: 'typesRoot', + value: [ + { type: 'string', key: 'stringType', value: 'string', path: '/types/string' }, + { type: 'number', key: 'numberType', value: 'number', path: '/types/number' }, + { type: 'boolean', key: 'booleanType', value: 'boolean', path: '/types/boolean' }, + { type: 'bigint', key: 'bigintType', value: 'bigint', path: '/types/bigint' }, + { type: 'symbol', key: 'symbolType', value: 'symbol', path: '/types/symbol' }, + { type: 'array', key: 'arrayType', value: [], path: '/types/array' }, + { type: 'object', key: 'objectType', value: [], path: '/types/object' }, + { + type: 'function', + key: 'functionType', + value: 'function', + path: '/types/function', + }, + { type: 'null', key: 'nullType', value: 'null', path: '/types/null' }, + { + type: 'undefined', + key: 'undefinedType', + value: 'undefined', + path: '/types/undefined', + }, + ], + path: '/types/root', + }, + }, + ], + inputSchema: { + nodeName: 'InputNode', + schema: { + type: 'object', + key: 'simpleInput', + value: [ + { + type: 'string', + key: 'simpleKey', + value: 'simpleValue', + path: '/simple/path', + }, + ], + path: '/simple/input/path', + }, + }, + pushRef: 'push-types-123', + ndvPushRef: 'ndv-push-types-456', + }, + forNode: 'TypeCheckNode', + }; + + const result = AiAskRequestDto.safeParse(allTypesRequest); + expect(result.success).toBe(true); + }); + + it('should fail with invalid type', () => { + const invalidTypeRequest = { + question: 'Test invalid type', + context: { + schema: [ + { + nodeName: 'InvalidTypeNode', + schema: { + type: 'invalid-type', // This should fail + key: 'invalidKey', + value: 'invalidValue', + path: '/invalid/path', + }, + }, + ], + inputSchema: { + nodeName: 'InputNode', + schema: { + type: 'object', + key: 'simpleInput', + value: [ + { + type: 'string', + key: 'simpleKey', + value: 'simpleValue', + path: '/simple/path', + }, + ], + path: '/simple/input/path', + }, + }, + pushRef: 'push-invalid-123', + ndvPushRef: 'ndv-push-invalid-456', + }, + forNode: 'InvalidTypeNode', + }; + + const result = AiAskRequestDto.safeParse(invalidTypeRequest); + expect(result.success).toBe(false); + }); + + it('should validate multiple schema entries', () => { + const multiSchemaRequest = { + question: 'Multiple schema test', + context: { + schema: [ + { + nodeName: 'FirstNode', + schema: { + type: 'string', + key: 'firstKey', + value: 'firstValue', + path: '/first/path', + }, + }, + { + nodeName: 'SecondNode', + schema: { + type: 'object', + key: 'secondKey', + value: [ + { + type: 'number', + key: 'nestedKey', + value: 'nestedValue', + path: '/second/nested/path', + }, + ], + path: '/second/path', + }, + }, + ], + inputSchema: { + nodeName: 'InputNode', + schema: { + type: 'object', + key: 'simpleInput', + value: [ + { + type: 'string', + key: 'simpleKey', + value: 'simpleValue', + path: '/simple/path', + }, + ], + path: '/simple/input/path', + }, + }, + pushRef: 'push-multi-123', + ndvPushRef: 'ndv-push-multi-456', + }, + forNode: 'MultiSchemaNode', + }; + + const result = AiAskRequestDto.safeParse(multiSchemaRequest); + expect(result.success).toBe(true); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/ai/__tests__/ai-chat-request.dto.test.ts b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-chat-request.dto.test.ts new file mode 100644 index 0000000000000..ce1ccffac5f95 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/__tests__/ai-chat-request.dto.test.ts @@ -0,0 +1,34 @@ +import { AiChatRequestDto } from '../ai-chat-request.dto'; + +describe('AiChatRequestDto', () => { + it('should validate a request with a payload and session ID', () => { + const validRequest = { + payload: { someKey: 'someValue' }, + sessionId: 'session-123', + }; + + const result = AiChatRequestDto.safeParse(validRequest); + + expect(result.success).toBe(true); + }); + + it('should validate a request with only a payload', () => { + const validRequest = { + payload: { complexObject: { nested: 'value' } }, + }; + + const result = AiChatRequestDto.safeParse(validRequest); + + expect(result.success).toBe(true); + }); + + it('should fail if payload is missing', () => { + const invalidRequest = { + sessionId: 'session-123', + }; + + const result = AiChatRequestDto.safeParse(invalidRequest); + + expect(result.success).toBe(false); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/ai/ai-apply-suggestion-request.dto.ts b/packages/@n8n/api-types/src/dto/ai/ai-apply-suggestion-request.dto.ts new file mode 100644 index 0000000000000..cc808dfd24a66 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/ai-apply-suggestion-request.dto.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +export class AiApplySuggestionRequestDto extends Z.class({ + sessionId: z.string(), + suggestionId: z.string(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/ai/ai-ask-request.dto.ts b/packages/@n8n/api-types/src/dto/ai/ai-ask-request.dto.ts new file mode 100644 index 0000000000000..9039243e051b2 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/ai-ask-request.dto.ts @@ -0,0 +1,53 @@ +import type { AiAssistantSDK, SchemaType } from '@n8n_io/ai-assistant-sdk'; +import { z } from 'zod'; +import { Z } from 'zod-class'; + +// Note: This is copied from the sdk, since this type is not exported +type Schema = { + type: SchemaType; + key?: string; + value: string | Schema[]; + path: string; +}; + +// Create a lazy validator to handle the recursive type +const schemaValidator: z.ZodType = z.lazy(() => + z.object({ + type: z.enum([ + 'string', + 'number', + 'boolean', + 'bigint', + 'symbol', + 'array', + 'object', + 'function', + 'null', + 'undefined', + ]), + key: z.string().optional(), + value: z.union([z.string(), z.lazy(() => schemaValidator.array())]), + path: z.string(), + }), +); + +export class AiAskRequestDto + extends Z.class({ + question: z.string(), + context: z.object({ + schema: z.array( + z.object({ + nodeName: z.string(), + schema: schemaValidator, + }), + ), + inputSchema: z.object({ + nodeName: z.string(), + schema: schemaValidator, + }), + pushRef: z.string(), + ndvPushRef: z.string(), + }), + forNode: z.string(), + }) + implements AiAssistantSDK.AskAiRequestPayload {} diff --git a/packages/@n8n/api-types/src/dto/ai/ai-chat-request.dto.ts b/packages/@n8n/api-types/src/dto/ai/ai-chat-request.dto.ts new file mode 100644 index 0000000000000..59e7a26aa3628 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/ai/ai-chat-request.dto.ts @@ -0,0 +1,10 @@ +import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; +import { z } from 'zod'; +import { Z } from 'zod-class'; + +export class AiChatRequestDto + extends Z.class({ + payload: z.object({}).passthrough(), // Allow any object shape + sessionId: z.string().optional(), + }) + implements AiAssistantSDK.ChatRequestPayload {} diff --git a/packages/@n8n/api-types/src/dto/index.ts b/packages/@n8n/api-types/src/dto/index.ts index 97d5d38459b4d..0e57e07110a54 100644 --- a/packages/@n8n/api-types/src/dto/index.ts +++ b/packages/@n8n/api-types/src/dto/index.ts @@ -1,3 +1,6 @@ +export { AiAskRequestDto } from './ai/ai-ask-request.dto'; +export { AiChatRequestDto } from './ai/ai-chat-request.dto'; +export { AiApplySuggestionRequestDto } from './ai/ai-apply-suggestion-request.dto'; export { PasswordUpdateRequestDto } from './user/password-update-request.dto'; export { RoleChangeRequestDto } from './user/role-change-request.dto'; export { SettingsUpdateRequestDto } from './user/settings-update-request.dto'; diff --git a/packages/@n8n/config/src/configs/aiAssistant.config.ts b/packages/@n8n/config/src/configs/aiAssistant.config.ts new file mode 100644 index 0000000000000..ff8a3986f2c4f --- /dev/null +++ b/packages/@n8n/config/src/configs/aiAssistant.config.ts @@ -0,0 +1,8 @@ +import { Config, Env } from '../decorators'; + +@Config +export class AiAssistantConfig { + /** Base URL of the AI assistant service */ + @Env('N8N_AI_ASSISTANT_BASE_URL') + baseUrl: string = ''; +} diff --git a/packages/@n8n/config/src/index.ts b/packages/@n8n/config/src/index.ts index a5144d419602f..945b5f123786d 100644 --- a/packages/@n8n/config/src/index.ts +++ b/packages/@n8n/config/src/index.ts @@ -1,3 +1,4 @@ +import { AiAssistantConfig } from './configs/aiAssistant.config'; import { CacheConfig } from './configs/cache.config'; import { CredentialsConfig } from './configs/credentials.config'; import { DatabaseConfig } from './configs/database.config'; @@ -121,4 +122,7 @@ export class GlobalConfig { @Nested diagnostics: DiagnosticsConfig; + + @Nested + aiAssistant: AiAssistantConfig; } diff --git a/packages/@n8n/config/test/config.test.ts b/packages/@n8n/config/test/config.test.ts index 771d915ee4970..d6d19c47fe2fc 100644 --- a/packages/@n8n/config/test/config.test.ts +++ b/packages/@n8n/config/test/config.test.ts @@ -289,6 +289,9 @@ describe('GlobalConfig', () => { apiHost: 'https://ph.n8n.io', }, }, + aiAssistant: { + baseUrl: '', + }, }; it('should use all default values when no env variables are defined', () => { diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index 54fa07e7f5dcb..e8d28cb782e7c 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -341,15 +341,6 @@ export const schema = { }, }, - aiAssistant: { - baseUrl: { - doc: 'Base URL of the AI assistant service', - format: String, - default: '', - env: 'N8N_AI_ASSISTANT_BASE_URL', - }, - }, - expression: { evaluator: { doc: 'Expression evaluator to use', diff --git a/packages/cli/src/controllers/__tests__/ai.controller.test.ts b/packages/cli/src/controllers/__tests__/ai.controller.test.ts new file mode 100644 index 0000000000000..30785ae938c07 --- /dev/null +++ b/packages/cli/src/controllers/__tests__/ai.controller.test.ts @@ -0,0 +1,111 @@ +import type { + AiAskRequestDto, + AiApplySuggestionRequestDto, + AiChatRequestDto, +} from '@n8n/api-types'; +import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; +import { mock } from 'jest-mock-extended'; + +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import type { AuthenticatedRequest } from '@/requests'; +import type { AiService } from '@/services/ai.service'; + +import { AiController, type FlushableResponse } from '../ai.controller'; + +describe('AiController', () => { + const aiService = mock(); + const controller = new AiController(aiService); + + const request = mock({ + user: { id: 'user123' }, + }); + const response = mock(); + + beforeEach(() => { + jest.clearAllMocks(); + + response.header.mockReturnThis(); + }); + + describe('chat', () => { + const payload = mock(); + + it('should handle chat request successfully', async () => { + aiService.chat.mockResolvedValue( + mock({ + body: mock({ + pipeTo: jest.fn().mockImplementation(async (writableStream) => { + // Simulate stream writing + const writer = writableStream.getWriter(); + await writer.write(JSON.stringify({ message: 'test response' })); + await writer.close(); + }), + }), + }), + ); + + await controller.chat(request, response, payload); + + expect(aiService.chat).toHaveBeenCalledWith(payload, request.user); + expect(response.header).toHaveBeenCalledWith('Content-type', 'application/json-lines'); + expect(response.flush).toHaveBeenCalled(); + expect(response.end).toHaveBeenCalled(); + }); + + it('should throw InternalServerError if chat fails', async () => { + const mockError = new Error('Chat failed'); + + aiService.chat.mockRejectedValue(mockError); + + await expect(controller.chat(request, response, payload)).rejects.toThrow( + InternalServerError, + ); + }); + }); + + describe('applySuggestion', () => { + const payload = mock(); + + it('should apply suggestion successfully', async () => { + const clientResponse = mock(); + aiService.applySuggestion.mockResolvedValue(clientResponse); + + const result = await controller.applySuggestion(request, response, payload); + + expect(aiService.applySuggestion).toHaveBeenCalledWith(payload, request.user); + expect(result).toEqual(clientResponse); + }); + + it('should throw InternalServerError if applying suggestion fails', async () => { + const mockError = new Error('Apply suggestion failed'); + aiService.applySuggestion.mockRejectedValue(mockError); + + await expect(controller.applySuggestion(request, response, payload)).rejects.toThrow( + InternalServerError, + ); + }); + }); + + describe('askAi method', () => { + const payload = mock(); + + it('should ask AI successfully', async () => { + const clientResponse = mock(); + aiService.askAi.mockResolvedValue(clientResponse); + + const result = await controller.askAi(request, response, payload); + + expect(aiService.askAi).toHaveBeenCalledWith(payload, request.user); + expect(result).toEqual(clientResponse); + }); + + it('should throw InternalServerError if asking AI fails', async () => { + const mockError = new Error('Ask AI failed'); + aiService.askAi.mockRejectedValue(mockError); + + await expect(controller.askAi(request, response, payload)).rejects.toThrow( + InternalServerError, + ); + }); + }); +}); diff --git a/packages/cli/src/controllers/ai.controller.ts b/packages/cli/src/controllers/ai.controller.ts index be1231911a001..59499112a3f9a 100644 --- a/packages/cli/src/controllers/ai.controller.ts +++ b/packages/cli/src/controllers/ai.controller.ts @@ -1,23 +1,24 @@ +import { AiChatRequestDto, AiApplySuggestionRequestDto, AiAskRequestDto } from '@n8n/api-types'; import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; -import type { Response } from 'express'; +import { Response } from 'express'; import { strict as assert } from 'node:assert'; import { WritableStream } from 'node:stream/web'; -import { Post, RestController } from '@/decorators'; +import { Body, Post, RestController } from '@/decorators'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; -import { AiAssistantRequest } from '@/requests'; +import { AuthenticatedRequest } from '@/requests'; import { AiService } from '@/services/ai.service'; -type FlushableResponse = Response & { flush: () => void }; +export type FlushableResponse = Response & { flush: () => void }; @RestController('/ai') export class AiController { constructor(private readonly aiService: AiService) {} @Post('/chat', { rateLimit: { limit: 100 } }) - async chat(req: AiAssistantRequest.Chat, res: FlushableResponse) { + async chat(req: AuthenticatedRequest, res: FlushableResponse, @Body payload: AiChatRequestDto) { try { - const aiResponse = await this.aiService.chat(req.body, req.user); + const aiResponse = await this.aiService.chat(payload, req.user); if (aiResponse.body) { res.header('Content-type', 'application/json-lines').flush(); await aiResponse.body.pipeTo( @@ -38,10 +39,12 @@ export class AiController { @Post('/chat/apply-suggestion') async applySuggestion( - req: AiAssistantRequest.ApplySuggestionPayload, + req: AuthenticatedRequest, + _: Response, + @Body payload: AiApplySuggestionRequestDto, ): Promise { try { - return await this.aiService.applySuggestion(req.body, req.user); + return await this.aiService.applySuggestion(payload, req.user); } catch (e) { assert(e instanceof Error); throw new InternalServerError(e.message, e); @@ -49,9 +52,13 @@ export class AiController { } @Post('/ask-ai') - async askAi(req: AiAssistantRequest.AskAiPayload): Promise { + async askAi( + req: AuthenticatedRequest, + _: Response, + @Body payload: AiAskRequestDto, + ): Promise { try { - return await this.aiService.askAi(req.body, req.user); + return await this.aiService.askAi(payload, req.user); } catch (e) { assert(e instanceof Error); throw new InternalServerError(e.message, e); diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index 7afb1e1bd3c7b..f7ac415a7547f 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -1,5 +1,4 @@ import type { Scope } from '@n8n/permissions'; -import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; import type express from 'express'; import type { BannerName, @@ -574,15 +573,3 @@ export declare namespace NpsSurveyRequest { // once some schema validation is added type NpsSurveyUpdate = AuthenticatedRequest<{}, {}, unknown>; } - -// ---------------------------------- -// /ai-assistant -// ---------------------------------- - -export declare namespace AiAssistantRequest { - type Chat = AuthenticatedRequest<{}, {}, AiAssistantSDK.ChatRequestPayload>; - - type SuggestionPayload = { sessionId: string; suggestionId: string }; - type ApplySuggestionPayload = AuthenticatedRequest<{}, {}, SuggestionPayload>; - type AskAiPayload = AuthenticatedRequest<{}, {}, AiAssistantSDK.AskAiRequestPayload>; -} diff --git a/packages/cli/src/services/__tests__/ai.service.test.ts b/packages/cli/src/services/__tests__/ai.service.test.ts new file mode 100644 index 0000000000000..dbdcaa3e718ff --- /dev/null +++ b/packages/cli/src/services/__tests__/ai.service.test.ts @@ -0,0 +1,132 @@ +import type { + AiAskRequestDto, + AiApplySuggestionRequestDto, + AiChatRequestDto, +} from '@n8n/api-types'; +import type { GlobalConfig } from '@n8n/config'; +import { AiAssistantClient, type AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; +import { mock } from 'jest-mock-extended'; +import type { IUser } from 'n8n-workflow'; + +import { N8N_VERSION } from '@/constants'; +import type { License } from '@/license'; + +import { AiService } from '../ai.service'; + +jest.mock('@n8n_io/ai-assistant-sdk', () => ({ + AiAssistantClient: jest.fn(), +})); + +describe('AiService', () => { + let aiService: AiService; + + const baseUrl = 'https://ai-assistant-url.com'; + const user = mock({ id: 'user123' }); + const client = mock(); + const license = mock(); + const globalConfig = mock({ + logging: { level: 'info' }, + aiAssistant: { baseUrl }, + }); + + beforeEach(() => { + jest.clearAllMocks(); + (AiAssistantClient as jest.Mock).mockImplementation(() => client); + aiService = new AiService(license, globalConfig); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + describe('init', () => { + it('should not initialize client if AI assistant is not enabled', async () => { + license.isAiAssistantEnabled.mockReturnValue(false); + + await aiService.init(); + + expect(AiAssistantClient).not.toHaveBeenCalled(); + }); + + it('should initialize client when AI assistant is enabled', async () => { + license.isAiAssistantEnabled.mockReturnValue(true); + license.loadCertStr.mockResolvedValue('mock-license-cert'); + license.getConsumerId.mockReturnValue('mock-consumer-id'); + + await aiService.init(); + + expect(AiAssistantClient).toHaveBeenCalledWith({ + licenseCert: 'mock-license-cert', + consumerId: 'mock-consumer-id', + n8nVersion: N8N_VERSION, + baseUrl, + logLevel: 'info', + }); + }); + }); + + describe('chat', () => { + const payload = mock(); + + it('should call client chat method after initialization', async () => { + license.isAiAssistantEnabled.mockReturnValue(true); + const clientResponse = mock(); + client.chat.mockResolvedValue(clientResponse); + + const result = await aiService.chat(payload, user); + + expect(client.chat).toHaveBeenCalledWith(payload, { id: user.id }); + expect(result).toEqual(clientResponse); + }); + + it('should throw error if client is not initialized', async () => { + license.isAiAssistantEnabled.mockReturnValue(false); + + await expect(aiService.chat(payload, user)).rejects.toThrow('Assistant client not setup'); + }); + }); + + describe('applySuggestion', () => { + const payload = mock(); + + it('should call client applySuggestion', async () => { + license.isAiAssistantEnabled.mockReturnValue(true); + const clientResponse = mock(); + client.applySuggestion.mockResolvedValue(clientResponse); + + const result = await aiService.applySuggestion(payload, user); + + expect(client.applySuggestion).toHaveBeenCalledWith(payload, { id: user.id }); + expect(result).toEqual(clientResponse); + }); + + it('should throw error if client is not initialized', async () => { + license.isAiAssistantEnabled.mockReturnValue(false); + + await expect(aiService.applySuggestion(payload, user)).rejects.toThrow( + 'Assistant client not setup', + ); + }); + }); + + describe('askAi', () => { + const payload = mock(); + + it('should call client askAi method after initialization', async () => { + license.isAiAssistantEnabled.mockReturnValue(true); + const clientResponse = mock(); + client.askAi.mockResolvedValue(clientResponse); + + const result = await aiService.askAi(payload, user); + + expect(client.askAi).toHaveBeenCalledWith(payload, { id: user.id }); + expect(result).toEqual(clientResponse); + }); + + it('should throw error if client is not initialized', async () => { + license.isAiAssistantEnabled.mockReturnValue(false); + + await expect(aiService.askAi(payload, user)).rejects.toThrow('Assistant client not setup'); + }); + }); +}); diff --git a/packages/cli/src/services/ai.service.ts b/packages/cli/src/services/ai.service.ts index a7b07219b5aca..74e28ad288841 100644 --- a/packages/cli/src/services/ai.service.ts +++ b/packages/cli/src/services/ai.service.ts @@ -1,12 +1,13 @@ +import type { + AiApplySuggestionRequestDto, + AiAskRequestDto, + AiChatRequestDto, +} from '@n8n/api-types'; import { GlobalConfig } from '@n8n/config'; -import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; import { AiAssistantClient } from '@n8n_io/ai-assistant-sdk'; import { assert, type IUser } from 'n8n-workflow'; import { Service } from 'typedi'; -import config from '@/config'; -import type { AiAssistantRequest } from '@/requests'; - import { N8N_VERSION } from '../constants'; import { License } from '../license'; @@ -27,7 +28,7 @@ export class AiService { const licenseCert = await this.licenseService.loadCertStr(); const consumerId = this.licenseService.getConsumerId(); - const baseUrl = config.get('aiAssistant.baseUrl'); + const baseUrl = this.globalConfig.aiAssistant.baseUrl; const logLevel = this.globalConfig.logging.level; this.client = new AiAssistantClient({ @@ -39,7 +40,7 @@ export class AiService { }); } - async chat(payload: AiAssistantSDK.ChatRequestPayload, user: IUser) { + async chat(payload: AiChatRequestDto, user: IUser) { if (!this.client) { await this.init(); } @@ -48,7 +49,7 @@ export class AiService { return await this.client.chat(payload, { id: user.id }); } - async applySuggestion(payload: AiAssistantRequest.SuggestionPayload, user: IUser) { + async applySuggestion(payload: AiApplySuggestionRequestDto, user: IUser) { if (!this.client) { await this.init(); } @@ -57,7 +58,7 @@ export class AiService { return await this.client.applySuggestion(payload, { id: user.id }); } - async askAi(payload: AiAssistantSDK.AskAiRequestPayload, user: IUser) { + async askAi(payload: AiAskRequestDto, user: IUser) { if (!this.client) { await this.init(); } From 371a09de968afe0a8ab6405c5c902146cf6bfa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 26 Dec 2024 16:09:42 +0100 Subject: [PATCH 04/43] refactor(core): Port 3 more controllers to use DTOs (no-changelog) (#12375) --- .../auth/__tests__/login-request.dto.test.ts | 93 ++++++++++++++ .../resolve-signup-token-query.dto.test.ts | 87 +++++++++++++ .../src/dto/auth/login-request.dto.ts | 9 ++ .../auth/resolve-signup-token-query.dto.ts | 7 ++ packages/@n8n/api-types/src/dto/index.ts | 13 ++ .../dismiss-banner-request.dto.test.ts | 64 ++++++++++ .../__tests__/owner-setup-request.dto.test.ts | 93 ++++++++++++++ .../dto/owner/dismiss-banner-request.dto.ts | 7 ++ .../src/dto/owner/owner-setup-request.dto.ts | 11 ++ .../change-password-request.dto.test.ts | 114 +++++++++++++++++ .../forgot-password-request.dto.test.ts | 47 +++++++ .../resolve-password-token-query.dto.test.ts | 42 +++++++ .../change-password-request.dto.ts | 11 ++ .../forgot-password-request.dto.ts | 6 + .../resolve-password-token-query.dto.ts | 7 ++ packages/@n8n/api-types/src/index.ts | 1 + .../src/schemas/bannerName.schema.ts | 11 ++ .../api-types/src/schemas/password.schema.ts | 16 +++ .../src/schemas/passwordResetToken.schema.ts | 3 + .../__tests__/owner.controller.test.ts | 117 ++++++++++-------- .../cli/src/controllers/auth.controller.ts | 43 +++---- .../cli/src/controllers/e2e.controller.ts | 11 +- .../cli/src/controllers/owner.controller.ts | 39 +++--- .../controllers/password-reset.controller.ts | 74 ++++------- .../cli/src/controllers/users.controller.ts | 12 +- packages/cli/src/decorators/index.ts | 2 +- .../variables/variables.controller.ee.ts | 12 +- packages/cli/src/requests.ts | 66 +--------- packages/cli/src/services/password.utility.ts | 1 + .../cli/test/integration/auth.api.test.ts | 15 +++ .../cli/test/integration/mfa/mfa.api.test.ts | 4 +- packages/editor-ui/src/Interface.ts | 2 +- packages/editor-ui/src/api/ui.ts | 2 +- .../src/components/banners/BaseBanner.vue | 2 +- packages/editor-ui/src/stores/ui.store.ts | 2 +- packages/workflow/src/Interfaces.ts | 7 -- 36 files changed, 813 insertions(+), 240 deletions(-) create mode 100644 packages/@n8n/api-types/src/dto/auth/__tests__/login-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/auth/__tests__/resolve-signup-token-query.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/auth/login-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/auth/resolve-signup-token-query.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/owner/__tests__/dismiss-banner-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/owner/__tests__/owner-setup-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/owner/dismiss-banner-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/owner/owner-setup-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/__tests__/change-password-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/__tests__/forgot-password-request.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/__tests__/resolve-password-token-query.dto.test.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/change-password-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/forgot-password-request.dto.ts create mode 100644 packages/@n8n/api-types/src/dto/password-reset/resolve-password-token-query.dto.ts create mode 100644 packages/@n8n/api-types/src/schemas/bannerName.schema.ts create mode 100644 packages/@n8n/api-types/src/schemas/password.schema.ts create mode 100644 packages/@n8n/api-types/src/schemas/passwordResetToken.schema.ts diff --git a/packages/@n8n/api-types/src/dto/auth/__tests__/login-request.dto.test.ts b/packages/@n8n/api-types/src/dto/auth/__tests__/login-request.dto.test.ts new file mode 100644 index 0000000000000..f222f1d93ecd9 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/auth/__tests__/login-request.dto.test.ts @@ -0,0 +1,93 @@ +import { LoginRequestDto } from '../login-request.dto'; + +describe('LoginRequestDto', () => { + describe('Valid requests', () => { + test.each([ + { + name: 'complete valid login request', + request: { + email: 'test@example.com', + password: 'securePassword123', + mfaCode: '123456', + }, + }, + { + name: 'login request without optional MFA', + request: { + email: 'test@example.com', + password: 'securePassword123', + }, + }, + { + name: 'login request with both mfaCode and mfaRecoveryCode', + request: { + email: 'test@example.com', + password: 'securePassword123', + mfaCode: '123456', + mfaRecoveryCode: 'recovery-code-123', + }, + }, + { + name: 'login request with only mfaRecoveryCode', + request: { + email: 'test@example.com', + password: 'securePassword123', + mfaRecoveryCode: 'recovery-code-123', + }, + }, + ])('should validate $name', ({ request }) => { + const result = LoginRequestDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'invalid email', + request: { + email: 'invalid-email', + password: 'securePassword123', + }, + expectedErrorPath: ['email'], + }, + { + name: 'empty password', + request: { + email: 'test@example.com', + password: '', + }, + expectedErrorPath: ['password'], + }, + { + name: 'missing email', + request: { + password: 'securePassword123', + }, + expectedErrorPath: ['email'], + }, + { + name: 'missing password', + request: { + email: 'test@example.com', + }, + expectedErrorPath: ['password'], + }, + { + name: 'whitespace in email and password', + request: { + email: ' test@example.com ', + password: ' securePassword123 ', + }, + expectedErrorPath: ['email'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = LoginRequestDto.safeParse(request); + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/auth/__tests__/resolve-signup-token-query.dto.test.ts b/packages/@n8n/api-types/src/dto/auth/__tests__/resolve-signup-token-query.dto.test.ts new file mode 100644 index 0000000000000..218fe9107a43e --- /dev/null +++ b/packages/@n8n/api-types/src/dto/auth/__tests__/resolve-signup-token-query.dto.test.ts @@ -0,0 +1,87 @@ +import { ResolveSignupTokenQueryDto } from '../resolve-signup-token-query.dto'; + +describe('ResolveSignupTokenQueryDto', () => { + const validUuid = '123e4567-e89b-12d3-a456-426614174000'; + + describe('Valid requests', () => { + test.each([ + { + name: 'standard UUID', + request: { + inviterId: validUuid, + inviteeId: validUuid, + }, + }, + ])('should validate $name', ({ request }) => { + const result = ResolveSignupTokenQueryDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'invalid inviterId UUID', + request: { + inviterId: 'not-a-valid-uuid', + inviteeId: validUuid, + }, + expectedErrorPath: ['inviterId'], + }, + { + name: 'invalid inviteeId UUID', + request: { + inviterId: validUuid, + inviteeId: 'not-a-valid-uuid', + }, + expectedErrorPath: ['inviteeId'], + }, + { + name: 'missing inviterId', + request: { + inviteeId: validUuid, + }, + expectedErrorPath: ['inviterId'], + }, + { + name: 'missing inviteeId', + request: { + inviterId: validUuid, + }, + expectedErrorPath: ['inviteeId'], + }, + { + name: 'UUID with invalid characters', + request: { + inviterId: '123e4567-e89b-12d3-a456-42661417400G', + inviteeId: validUuid, + }, + expectedErrorPath: ['inviterId'], + }, + { + name: 'UUID too long', + request: { + inviterId: '123e4567-e89b-12d3-a456-426614174001234', + inviteeId: validUuid, + }, + expectedErrorPath: ['inviterId'], + }, + { + name: 'UUID too short', + request: { + inviterId: '123e4567-e89b-12d3-a456', + inviteeId: validUuid, + }, + expectedErrorPath: ['inviterId'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = ResolveSignupTokenQueryDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/auth/login-request.dto.ts b/packages/@n8n/api-types/src/dto/auth/login-request.dto.ts new file mode 100644 index 0000000000000..894263992c6e0 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/auth/login-request.dto.ts @@ -0,0 +1,9 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +export class LoginRequestDto extends Z.class({ + email: z.string().email(), + password: z.string().min(1), + mfaCode: z.string().optional(), + mfaRecoveryCode: z.string().optional(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/auth/resolve-signup-token-query.dto.ts b/packages/@n8n/api-types/src/dto/auth/resolve-signup-token-query.dto.ts new file mode 100644 index 0000000000000..768202ff04ed9 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/auth/resolve-signup-token-query.dto.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +export class ResolveSignupTokenQueryDto extends Z.class({ + inviterId: z.string().uuid(), + inviteeId: z.string().uuid(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/index.ts b/packages/@n8n/api-types/src/dto/index.ts index 0e57e07110a54..96f55087a159a 100644 --- a/packages/@n8n/api-types/src/dto/index.ts +++ b/packages/@n8n/api-types/src/dto/index.ts @@ -1,9 +1,22 @@ export { AiAskRequestDto } from './ai/ai-ask-request.dto'; export { AiChatRequestDto } from './ai/ai-chat-request.dto'; export { AiApplySuggestionRequestDto } from './ai/ai-apply-suggestion-request.dto'; + +export { LoginRequestDto } from './auth/login-request.dto'; +export { ResolveSignupTokenQueryDto } from './auth/resolve-signup-token-query.dto'; + +export { OwnerSetupRequestDto } from './owner/owner-setup-request.dto'; +export { DismissBannerRequestDto } from './owner/dismiss-banner-request.dto'; + +export { ForgotPasswordRequestDto } from './password-reset/forgot-password-request.dto'; +export { ResolvePasswordTokenQueryDto } from './password-reset/resolve-password-token-query.dto'; +export { ChangePasswordRequestDto } from './password-reset/change-password-request.dto'; + export { PasswordUpdateRequestDto } from './user/password-update-request.dto'; export { RoleChangeRequestDto } from './user/role-change-request.dto'; export { SettingsUpdateRequestDto } from './user/settings-update-request.dto'; export { UserUpdateRequestDto } from './user/user-update-request.dto'; + export { CommunityRegisteredRequestDto } from './license/community-registered-request.dto'; + export { VariableListRequestDto } from './variables/variables-list-request.dto'; diff --git a/packages/@n8n/api-types/src/dto/owner/__tests__/dismiss-banner-request.dto.test.ts b/packages/@n8n/api-types/src/dto/owner/__tests__/dismiss-banner-request.dto.test.ts new file mode 100644 index 0000000000000..97371de16a10c --- /dev/null +++ b/packages/@n8n/api-types/src/dto/owner/__tests__/dismiss-banner-request.dto.test.ts @@ -0,0 +1,64 @@ +import { bannerNameSchema } from '../../../schemas/bannerName.schema'; +import { DismissBannerRequestDto } from '../dismiss-banner-request.dto'; + +describe('DismissBannerRequestDto', () => { + describe('Valid requests', () => { + test.each( + bannerNameSchema.options.map((banner) => ({ + name: `valid banner: ${banner}`, + request: { banner }, + })), + )('should validate $name', ({ request }) => { + const result = DismissBannerRequestDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'invalid banner string', + request: { + banner: 'not-a-valid-banner', + }, + expectedErrorPath: ['banner'], + }, + { + name: 'non-string banner', + request: { + banner: 123, + }, + expectedErrorPath: ['banner'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = DismissBannerRequestDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); + + describe('Optional banner', () => { + test('should validate empty request', () => { + const result = DismissBannerRequestDto.safeParse({}); + expect(result.success).toBe(true); + }); + }); + + describe('Exhaustive banner name check', () => { + test('should have all banner names defined', () => { + const expectedBanners = [ + 'V1', + 'TRIAL_OVER', + 'TRIAL', + 'NON_PRODUCTION_LICENSE', + 'EMAIL_CONFIRMATION', + ]; + + expect(bannerNameSchema.options).toEqual(expectedBanners); + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/owner/__tests__/owner-setup-request.dto.test.ts b/packages/@n8n/api-types/src/dto/owner/__tests__/owner-setup-request.dto.test.ts new file mode 100644 index 0000000000000..facf808ec3f34 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/owner/__tests__/owner-setup-request.dto.test.ts @@ -0,0 +1,93 @@ +import { OwnerSetupRequestDto } from '../owner-setup-request.dto'; + +describe('OwnerSetupRequestDto', () => { + describe('Valid requests', () => { + test.each([ + { + name: 'complete valid setup request', + request: { + email: 'owner@example.com', + firstName: 'John', + lastName: 'Doe', + password: 'SecurePassword123', + }, + }, + ])('should validate $name', ({ request }) => { + const result = OwnerSetupRequestDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'invalid email', + request: { + email: 'invalid-email', + firstName: 'John', + lastName: 'Doe', + password: 'SecurePassword123', + }, + expectedErrorPath: ['email'], + }, + { + name: 'missing first name', + request: { + email: 'owner@example.com', + firstName: '', + lastName: 'Doe', + password: 'SecurePassword123', + }, + expectedErrorPath: ['firstName'], + }, + { + name: 'missing last name', + request: { + email: 'owner@example.com', + firstName: 'John', + lastName: '', + password: 'SecurePassword123', + }, + expectedErrorPath: ['lastName'], + }, + { + name: 'password too short', + request: { + email: 'owner@example.com', + firstName: 'John', + lastName: 'Doe', + password: 'short', + }, + expectedErrorPath: ['password'], + }, + { + name: 'password without number', + request: { + email: 'owner@example.com', + firstName: 'John', + lastName: 'Doe', + password: 'NoNumberPassword', + }, + expectedErrorPath: ['password'], + }, + { + name: 'password without uppercase letter', + request: { + email: 'owner@example.com', + firstName: 'John', + lastName: 'Doe', + password: 'nouppercasepassword123', + }, + expectedErrorPath: ['password'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = OwnerSetupRequestDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/owner/dismiss-banner-request.dto.ts b/packages/@n8n/api-types/src/dto/owner/dismiss-banner-request.dto.ts new file mode 100644 index 0000000000000..1f42381e7a71a --- /dev/null +++ b/packages/@n8n/api-types/src/dto/owner/dismiss-banner-request.dto.ts @@ -0,0 +1,7 @@ +import { Z } from 'zod-class'; + +import { bannerNameSchema } from '../../schemas/bannerName.schema'; + +export class DismissBannerRequestDto extends Z.class({ + banner: bannerNameSchema.optional(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/owner/owner-setup-request.dto.ts b/packages/@n8n/api-types/src/dto/owner/owner-setup-request.dto.ts new file mode 100644 index 0000000000000..ccaa06b18e78a --- /dev/null +++ b/packages/@n8n/api-types/src/dto/owner/owner-setup-request.dto.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +import { passwordSchema } from '../../schemas/password.schema'; + +export class OwnerSetupRequestDto extends Z.class({ + email: z.string().email(), + firstName: z.string().min(1, 'First name is required'), + lastName: z.string().min(1, 'Last name is required'), + password: passwordSchema, +}) {} diff --git a/packages/@n8n/api-types/src/dto/password-reset/__tests__/change-password-request.dto.test.ts b/packages/@n8n/api-types/src/dto/password-reset/__tests__/change-password-request.dto.test.ts new file mode 100644 index 0000000000000..86b230ba5ad4d --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/__tests__/change-password-request.dto.test.ts @@ -0,0 +1,114 @@ +import { ChangePasswordRequestDto } from '../change-password-request.dto'; + +describe('ChangePasswordRequestDto', () => { + describe('Valid requests', () => { + test.each([ + { + name: 'valid password reset with token', + request: { + token: 'valid-reset-token-with-sufficient-length', + password: 'newSecurePassword123', + }, + }, + { + name: 'valid password reset with MFA code', + request: { + token: 'another-valid-reset-token', + password: 'newSecurePassword123', + mfaCode: '123456', + }, + }, + ])('should validate $name', ({ request }) => { + const result = ChangePasswordRequestDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'missing token', + request: { password: 'newSecurePassword123' }, + expectedErrorPath: ['token'], + }, + { + name: 'empty token', + request: { token: '', password: 'newSecurePassword123' }, + expectedErrorPath: ['token'], + }, + { + name: 'short token', + request: { token: 'short', password: 'newSecurePassword123' }, + expectedErrorPath: ['token'], + }, + { + name: 'missing password', + request: { token: 'valid-reset-token' }, + expectedErrorPath: ['password'], + }, + { + name: 'password too short', + request: { + token: 'valid-reset-token', + password: 'short', + }, + expectedErrorPath: ['password'], + }, + { + name: 'password too long', + request: { + token: 'valid-reset-token', + password: 'a'.repeat(65), + }, + expectedErrorPath: ['password'], + }, + { + name: 'password without number', + request: { + token: 'valid-reset-token', + password: 'NoNumberPassword', + }, + expectedErrorPath: ['password'], + }, + { + name: 'password without uppercase letter', + request: { + token: 'valid-reset-token', + password: 'nouppercasepassword123', + }, + expectedErrorPath: ['password'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = ChangePasswordRequestDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + + describe('Edge cases', () => { + test('should handle optional MFA code correctly', () => { + const validRequest = { + token: 'valid-reset-token', + password: 'newSecurePassword123', + mfaCode: undefined, + }; + + const result = ChangePasswordRequestDto.safeParse(validRequest); + expect(result.success).toBe(true); + }); + + test('should handle token with special characters', () => { + const validRequest = { + token: 'valid-reset-token-with-special-!@#$%^&*()_+', + password: 'newSecurePassword123', + }; + + const result = ChangePasswordRequestDto.safeParse(validRequest); + expect(result.success).toBe(true); + }); + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/password-reset/__tests__/forgot-password-request.dto.test.ts b/packages/@n8n/api-types/src/dto/password-reset/__tests__/forgot-password-request.dto.test.ts new file mode 100644 index 0000000000000..891d52fdad022 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/__tests__/forgot-password-request.dto.test.ts @@ -0,0 +1,47 @@ +import { ForgotPasswordRequestDto } from '../forgot-password-request.dto'; + +describe('ForgotPasswordRequestDto', () => { + describe('Valid requests', () => { + test.each([ + { + name: 'valid email', + request: { email: 'test@example.com' }, + }, + { + name: 'email with subdomain', + request: { email: 'user@sub.example.com' }, + }, + ])('should validate $name', ({ request }) => { + const result = ForgotPasswordRequestDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'invalid email format', + request: { email: 'invalid-email' }, + expectedErrorPath: ['email'], + }, + { + name: 'missing email', + request: {}, + expectedErrorPath: ['email'], + }, + { + name: 'empty email', + request: { email: '' }, + expectedErrorPath: ['email'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = ForgotPasswordRequestDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/password-reset/__tests__/resolve-password-token-query.dto.test.ts b/packages/@n8n/api-types/src/dto/password-reset/__tests__/resolve-password-token-query.dto.test.ts new file mode 100644 index 0000000000000..a2f5881ac81a6 --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/__tests__/resolve-password-token-query.dto.test.ts @@ -0,0 +1,42 @@ +import { ResolvePasswordTokenQueryDto } from '../resolve-password-token-query.dto'; + +describe('ResolvePasswordTokenQueryDto', () => { + describe('Valid requests', () => { + test.each([ + { + name: 'valid token', + request: { token: 'valid-reset-token' }, + }, + { + name: 'long token', + request: { token: 'x'.repeat(50) }, + }, + ])('should validate $name', ({ request }) => { + const result = ResolvePasswordTokenQueryDto.safeParse(request); + expect(result.success).toBe(true); + }); + }); + + describe('Invalid requests', () => { + test.each([ + { + name: 'missing token', + request: {}, + expectedErrorPath: ['token'], + }, + { + name: 'empty token', + request: { token: '' }, + expectedErrorPath: ['token'], + }, + ])('should fail validation for $name', ({ request, expectedErrorPath }) => { + const result = ResolvePasswordTokenQueryDto.safeParse(request); + + expect(result.success).toBe(false); + + if (expectedErrorPath) { + expect(result.error?.issues[0].path).toEqual(expectedErrorPath); + } + }); + }); +}); diff --git a/packages/@n8n/api-types/src/dto/password-reset/change-password-request.dto.ts b/packages/@n8n/api-types/src/dto/password-reset/change-password-request.dto.ts new file mode 100644 index 0000000000000..33ef47b3f173f --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/change-password-request.dto.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +import { passwordSchema } from '../../schemas/password.schema'; +import { passwordResetTokenSchema } from '../../schemas/passwordResetToken.schema'; + +export class ChangePasswordRequestDto extends Z.class({ + token: passwordResetTokenSchema, + password: passwordSchema, + mfaCode: z.string().optional(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/password-reset/forgot-password-request.dto.ts b/packages/@n8n/api-types/src/dto/password-reset/forgot-password-request.dto.ts new file mode 100644 index 0000000000000..f6ab3cfac5bcc --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/forgot-password-request.dto.ts @@ -0,0 +1,6 @@ +import { z } from 'zod'; +import { Z } from 'zod-class'; + +export class ForgotPasswordRequestDto extends Z.class({ + email: z.string().email(), +}) {} diff --git a/packages/@n8n/api-types/src/dto/password-reset/resolve-password-token-query.dto.ts b/packages/@n8n/api-types/src/dto/password-reset/resolve-password-token-query.dto.ts new file mode 100644 index 0000000000000..88385df244e8d --- /dev/null +++ b/packages/@n8n/api-types/src/dto/password-reset/resolve-password-token-query.dto.ts @@ -0,0 +1,7 @@ +import { Z } from 'zod-class'; + +import { passwordResetTokenSchema } from '../../schemas/passwordResetToken.schema'; + +export class ResolvePasswordTokenQueryDto extends Z.class({ + token: passwordResetTokenSchema, +}) {} diff --git a/packages/@n8n/api-types/src/index.ts b/packages/@n8n/api-types/src/index.ts index d0067f7fff67e..b446ca3971903 100644 --- a/packages/@n8n/api-types/src/index.ts +++ b/packages/@n8n/api-types/src/index.ts @@ -5,5 +5,6 @@ export type * from './scaling'; export type * from './frontend-settings'; export type * from './user'; +export type { BannerName } from './schemas/bannerName.schema'; export type { Collaborator } from './push/collaboration'; export type { SendWorkerStatusMessage } from './push/worker'; diff --git a/packages/@n8n/api-types/src/schemas/bannerName.schema.ts b/packages/@n8n/api-types/src/schemas/bannerName.schema.ts new file mode 100644 index 0000000000000..445bc31d1ad52 --- /dev/null +++ b/packages/@n8n/api-types/src/schemas/bannerName.schema.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; + +export const bannerNameSchema = z.enum([ + 'V1', + 'TRIAL_OVER', + 'TRIAL', + 'NON_PRODUCTION_LICENSE', + 'EMAIL_CONFIRMATION', +]); + +export type BannerName = z.infer; diff --git a/packages/@n8n/api-types/src/schemas/password.schema.ts b/packages/@n8n/api-types/src/schemas/password.schema.ts new file mode 100644 index 0000000000000..3c60470af730d --- /dev/null +++ b/packages/@n8n/api-types/src/schemas/password.schema.ts @@ -0,0 +1,16 @@ +import { z } from 'zod'; + +// TODO: Delete these from `cli` after all password-validation code starts using this schema +const minLength = 8; +const maxLength = 64; + +export const passwordSchema = z + .string() + .min(minLength, `Password must be ${minLength} to ${maxLength} characters long.`) + .max(maxLength, `Password must be ${minLength} to ${maxLength} characters long.`) + .refine((password) => /\d/.test(password), { + message: 'Password must contain at least 1 number.', + }) + .refine((password) => /[A-Z]/.test(password), { + message: 'Password must contain at least 1 uppercase letter.', + }); diff --git a/packages/@n8n/api-types/src/schemas/passwordResetToken.schema.ts b/packages/@n8n/api-types/src/schemas/passwordResetToken.schema.ts new file mode 100644 index 0000000000000..b7c55bb8869fb --- /dev/null +++ b/packages/@n8n/api-types/src/schemas/passwordResetToken.schema.ts @@ -0,0 +1,3 @@ +import { z } from 'zod'; + +export const passwordResetTokenSchema = z.string().min(10, 'Token too short'); diff --git a/packages/cli/src/controllers/__tests__/owner.controller.test.ts b/packages/cli/src/controllers/__tests__/owner.controller.test.ts index 0fd42aae438f1..b5065fa283688 100644 --- a/packages/cli/src/controllers/__tests__/owner.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/owner.controller.test.ts @@ -1,7 +1,7 @@ +import type { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types'; import type { Response } from 'express'; -import { anyObject, mock } from 'jest-mock-extended'; -import jwt from 'jsonwebtoken'; -import Container from 'typedi'; +import { mock } from 'jest-mock-extended'; +import type { Logger } from 'n8n-core'; import type { AuthService } from '@/auth/auth.service'; import config from '@/config'; @@ -10,27 +10,31 @@ import type { User } from '@/databases/entities/user'; import type { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { UserRepository } from '@/databases/repositories/user.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { License } from '@/license'; -import type { OwnerRequest } from '@/requests'; -import { PasswordUtility } from '@/services/password.utility'; +import type { EventService } from '@/events/event.service'; +import type { PublicUser } from '@/interfaces'; +import type { AuthenticatedRequest } from '@/requests'; +import type { PasswordUtility } from '@/services/password.utility'; import type { UserService } from '@/services/user.service'; -import { mockInstance } from '@test/mocking'; -import { badPasswords } from '@test/test-data'; describe('OwnerController', () => { const configGetSpy = jest.spyOn(config, 'getEnv'); + const configSetSpy = jest.spyOn(config, 'set'); + + const logger = mock(); + const eventService = mock(); const authService = mock(); const userService = mock(); const userRepository = mock(); const settingsRepository = mock(); - mockInstance(License).isWithinUsersLimit.mockReturnValue(true); + const passwordUtility = mock(); + const controller = new OwnerController( - mock(), - mock(), + logger, + eventService, settingsRepository, authService, userService, - Container.get(PasswordUtility), + passwordUtility, mock(), userRepository, ); @@ -38,38 +42,18 @@ describe('OwnerController', () => { describe('setupOwner', () => { it('should throw a BadRequestError if the instance owner is already setup', async () => { configGetSpy.mockReturnValue(true); - await expect(controller.setupOwner(mock(), mock())).rejects.toThrowError( + await expect(controller.setupOwner(mock(), mock(), mock())).rejects.toThrowError( new BadRequestError('Instance owner already setup'), ); - }); - it('should throw a BadRequestError if the email is invalid', async () => { - configGetSpy.mockReturnValue(false); - const req = mock({ body: { email: 'invalid email' } }); - await expect(controller.setupOwner(req, mock())).rejects.toThrowError( - new BadRequestError('Invalid email address'), - ); - }); - - describe('should throw if the password is invalid', () => { - Object.entries(badPasswords).forEach(([password, errorMessage]) => { - it(password, async () => { - configGetSpy.mockReturnValue(false); - const req = mock({ body: { email: 'valid@email.com', password } }); - await expect(controller.setupOwner(req, mock())).rejects.toThrowError( - new BadRequestError(errorMessage), - ); - }); - }); - }); - - it('should throw a BadRequestError if firstName & lastName are missing ', async () => { - configGetSpy.mockReturnValue(false); - const req = mock({ - body: { email: 'valid@email.com', password: 'NewPassword123', firstName: '', lastName: '' }, - }); - await expect(controller.setupOwner(req, mock())).rejects.toThrowError( - new BadRequestError('First and last names are mandatory'), + expect(userRepository.findOneOrFail).not.toHaveBeenCalled(); + expect(userRepository.save).not.toHaveBeenCalled(); + expect(authService.issueCookie).not.toHaveBeenCalled(); + expect(settingsRepository.update).not.toHaveBeenCalled(); + expect(configSetSpy).not.toHaveBeenCalled(); + expect(eventService.emit).not.toHaveBeenCalled(); + expect(logger.debug).toHaveBeenCalledWith( + 'Request to claim instance ownership failed because instance owner already exists', ); }); @@ -80,29 +64,52 @@ describe('OwnerController', () => { authIdentities: [], }); const browserId = 'test-browser-id'; - const req = mock({ - body: { - email: 'valid@email.com', - password: 'NewPassword123', - firstName: 'Jane', - lastName: 'Doe', - }, - user, - browserId, - }); + const req = mock({ user, browserId }); const res = mock(); + const payload = mock({ + email: 'valid@email.com', + password: 'NewPassword123', + firstName: 'Jane', + lastName: 'Doe', + }); configGetSpy.mockReturnValue(false); - userRepository.findOneOrFail.calledWith(anyObject()).mockResolvedValue(user); - userRepository.save.calledWith(anyObject()).mockResolvedValue(user); - jest.spyOn(jwt, 'sign').mockImplementation(() => 'signed-token'); + userRepository.findOneOrFail.mockResolvedValue(user); + userRepository.save.mockResolvedValue(user); + userService.toPublic.mockResolvedValue(mock({ id: 'newUserId' })); - await controller.setupOwner(req, res); + const result = await controller.setupOwner(req, res, payload); expect(userRepository.findOneOrFail).toHaveBeenCalledWith({ where: { role: 'global:owner' }, }); expect(userRepository.save).toHaveBeenCalledWith(user, { transaction: false }); expect(authService.issueCookie).toHaveBeenCalledWith(res, user, browserId); + expect(settingsRepository.update).toHaveBeenCalledWith( + { key: 'userManagement.isInstanceOwnerSetUp' }, + { value: JSON.stringify(true) }, + ); + expect(configSetSpy).toHaveBeenCalledWith('userManagement.isInstanceOwnerSetUp', true); + expect(eventService.emit).toHaveBeenCalledWith('instance-owner-setup', { userId: 'userId' }); + expect(result.id).toEqual('newUserId'); + }); + }); + + describe('dismissBanner', () => { + it('should not call dismissBanner if no banner is provided', async () => { + const payload = mock({ banner: undefined }); + + const result = await controller.dismissBanner(mock(), mock(), payload); + + expect(settingsRepository.dismissBanner).not.toHaveBeenCalled(); + expect(result).toBeUndefined(); + }); + + it('should call dismissBanner with the correct banner name', async () => { + const payload = mock({ banner: 'TRIAL' }); + + await controller.dismissBanner(mock(), mock(), payload); + + expect(settingsRepository.dismissBanner).toHaveBeenCalledWith({ bannerName: 'TRIAL' }); }); }); }); diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index b012e571312ab..fb06c1a80b96c 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -1,14 +1,13 @@ +import { LoginRequestDto, ResolveSignupTokenQueryDto } from '@n8n/api-types'; import { Response } from 'express'; import { Logger } from 'n8n-core'; -import { ApplicationError } from 'n8n-workflow'; -import validator from 'validator'; import { handleEmailLogin, handleLdapLogin } from '@/auth'; import { AuthService } from '@/auth/auth.service'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import type { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { Get, Post, RestController } from '@/decorators'; +import { Body, Get, Post, Query, RestController } from '@/decorators'; import { AuthError } from '@/errors/response-errors/auth.error'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; @@ -17,7 +16,7 @@ import type { PublicUser } from '@/interfaces'; import { License } from '@/license'; import { MfaService } from '@/mfa/mfa.service'; import { PostHogClient } from '@/posthog'; -import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests'; +import { AuthenticatedRequest, AuthlessRequest } from '@/requests'; import { UserService } from '@/services/user.service'; import { getCurrentAuthenticationMethod, @@ -40,10 +39,12 @@ export class AuthController { /** Log in a user */ @Post('/login', { skipAuth: true, rateLimit: true }) - async login(req: LoginRequest, res: Response): Promise { - const { email, password, mfaCode, mfaRecoveryCode } = req.body; - if (!email) throw new ApplicationError('Email is required to log in'); - if (!password) throw new ApplicationError('Password is required to log in'); + async login( + req: AuthlessRequest, + res: Response, + @Body payload: LoginRequestDto, + ): Promise { + const { email, password, mfaCode, mfaRecoveryCode } = payload; let user: User | undefined; @@ -117,8 +118,12 @@ export class AuthController { /** Validate invite token to enable invitee to set up their account */ @Get('/resolve-signup-token', { skipAuth: true }) - async resolveSignupToken(req: UserRequest.ResolveSignUp) { - const { inviterId, inviteeId } = req.query; + async resolveSignupToken( + _req: AuthlessRequest, + _res: Response, + @Query payload: ResolveSignupTokenQueryDto, + ) { + const { inviterId, inviteeId } = payload; const isWithinUsersLimit = this.license.isWithinUsersLimit(); if (!isWithinUsersLimit) { @@ -129,24 +134,6 @@ export class AuthController { throw new ForbiddenError(RESPONSE_ERROR_MESSAGES.USERS_QUOTA_REACHED); } - if (!inviterId || !inviteeId) { - this.logger.debug( - 'Request to resolve signup token failed because of missing user IDs in query string', - { inviterId, inviteeId }, - ); - throw new BadRequestError('Invalid payload'); - } - - // Postgres validates UUID format - for (const userId of [inviterId, inviteeId]) { - if (!validator.isUUID(userId)) { - this.logger.debug('Request to resolve signup token failed because of invalid user ID', { - userId, - }); - throw new BadRequestError('Invalid userId'); - } - } - const users = await this.userRepository.findManyByIds([inviterId, inviteeId]); if (users.length !== 2) { diff --git a/packages/cli/src/controllers/e2e.controller.ts b/packages/cli/src/controllers/e2e.controller.ts index 9d0404d3126d2..4430dfc9fa7fc 100644 --- a/packages/cli/src/controllers/e2e.controller.ts +++ b/packages/cli/src/controllers/e2e.controller.ts @@ -17,7 +17,6 @@ import type { FeatureReturnType } from '@/license'; import { License } from '@/license'; import { MfaService } from '@/mfa/mfa.service'; import { Push } from '@/push'; -import type { UserSetupPayload } from '@/requests'; import { CacheService } from '@/services/cache/cache.service'; import { PasswordUtility } from '@/services/password.utility'; @@ -48,6 +47,16 @@ const tablesToTruncate = [ 'workflows_tags', ]; +type UserSetupPayload = { + email: string; + password: string; + firstName: string; + lastName: string; + mfaEnabled?: boolean; + mfaSecret?: string; + mfaRecoveryCodes?: string[]; +}; + type ResetRequest = Request< {}, {}, diff --git a/packages/cli/src/controllers/owner.controller.ts b/packages/cli/src/controllers/owner.controller.ts index 1db250c488a40..5c7e8d1e2ac84 100644 --- a/packages/cli/src/controllers/owner.controller.ts +++ b/packages/cli/src/controllers/owner.controller.ts @@ -1,17 +1,17 @@ +import { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types'; import { Response } from 'express'; import { Logger } from 'n8n-core'; -import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { GlobalScope, Post, RestController } from '@/decorators'; +import { Body, GlobalScope, Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; import { validateEntity } from '@/generic-helpers'; import { PostHogClient } from '@/posthog'; -import { OwnerRequest } from '@/requests'; +import { AuthenticatedRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; @@ -33,8 +33,8 @@ export class OwnerController { * and enable `isInstanceOwnerSetUp` setting. */ @Post('/setup', { skipAuth: true }) - async setupOwner(req: OwnerRequest.Post, res: Response) { - const { email, firstName, lastName, password } = req.body; + async setupOwner(req: AuthenticatedRequest, res: Response, @Body payload: OwnerSetupRequestDto) { + const { email, firstName, lastName, password } = payload; if (config.getEnv('userManagement.isInstanceOwnerSetUp')) { this.logger.debug( @@ -43,31 +43,15 @@ export class OwnerController { throw new BadRequestError('Instance owner already setup'); } - if (!email || !validator.isEmail(email)) { - this.logger.debug('Request to claim instance ownership failed because of invalid email', { - invalidEmail: email, - }); - throw new BadRequestError('Invalid email address'); - } - - const validPassword = this.passwordUtility.validate(password); - - if (!firstName || !lastName) { - this.logger.debug( - 'Request to claim instance ownership failed because of missing first name or last name in payload', - { payload: req.body }, - ); - throw new BadRequestError('First and last names are mandatory'); - } - let owner = await this.userRepository.findOneOrFail({ where: { role: 'global:owner' }, }); owner.email = email; owner.firstName = firstName; owner.lastName = lastName; - owner.password = await this.passwordUtility.hash(validPassword); + owner.password = await this.passwordUtility.hash(password); + // TODO: move XSS validation out into the DTO class await validateEntity(owner); owner = await this.userRepository.save(owner, { transaction: false }); @@ -92,8 +76,13 @@ export class OwnerController { @Post('/dismiss-banner') @GlobalScope('banner:dismiss') - async dismissBanner(req: OwnerRequest.DismissBanner) { - const bannerName = 'banner' in req.body ? (req.body.banner as string) : ''; + async dismissBanner( + _req: AuthenticatedRequest, + _res: Response, + @Body payload: DismissBannerRequestDto, + ) { + const bannerName = payload.banner; + if (!bannerName) return; return await this.settingsRepository.dismissBanner({ bannerName }); } } diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index 7fc266c8e84e3..c2652aa785891 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -1,11 +1,15 @@ +import { + ChangePasswordRequestDto, + ForgotPasswordRequestDto, + ResolvePasswordTokenQueryDto, +} from '@n8n/api-types'; import { Response } from 'express'; import { Logger } from 'n8n-core'; -import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { Get, Post, RestController } from '@/decorators'; +import { Body, Get, Post, Query, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; @@ -15,7 +19,7 @@ import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; import { MfaService } from '@/mfa/mfa.service'; -import { PasswordResetRequest } from '@/requests'; +import { AuthlessRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; import { isSamlCurrentAuthenticationMethod } from '@/sso.ee/sso-helpers'; @@ -40,7 +44,11 @@ export class PasswordResetController { * Send a password reset email. */ @Post('/forgot-password', { skipAuth: true, rateLimit: { limit: 3 } }) - async forgotPassword(req: PasswordResetRequest.Email) { + async forgotPassword( + _req: AuthlessRequest, + _res: Response, + @Body payload: ForgotPasswordRequestDto, + ) { if (!this.mailer.isEmailSetUp) { this.logger.debug( 'Request to send password reset email failed because emailing was not set up', @@ -50,22 +58,7 @@ export class PasswordResetController { ); } - const { email } = req.body; - if (!email) { - this.logger.debug( - 'Request to send password reset email failed because of missing email in payload', - { payload: req.body }, - ); - throw new BadRequestError('Email is mandatory'); - } - - if (!validator.isEmail(email)) { - this.logger.debug( - 'Request to send password reset email failed because of invalid email in payload', - { invalidEmail: email }, - ); - throw new BadRequestError('Invalid email address'); - } + const { email } = payload; // User should just be able to reset password if one is already present const user = await this.userRepository.findNonShellUser(email); @@ -138,19 +131,12 @@ export class PasswordResetController { * Verify password reset token and user ID. */ @Get('/resolve-password-token', { skipAuth: true }) - async resolvePasswordToken(req: PasswordResetRequest.Credentials) { - const { token } = req.query; - - if (!token) { - this.logger.debug( - 'Request to resolve password token failed because of missing password reset token', - { - queryString: req.query, - }, - ); - throw new BadRequestError(''); - } - + async resolvePasswordToken( + _req: AuthlessRequest, + _res: Response, + @Query payload: ResolvePasswordTokenQueryDto, + ) { + const { token } = payload; const user = await this.authService.resolvePasswordResetToken(token); if (!user) throw new NotFoundError(''); @@ -170,20 +156,12 @@ export class PasswordResetController { * Verify password reset token and update password. */ @Post('/change-password', { skipAuth: true }) - async changePassword(req: PasswordResetRequest.NewPassword, res: Response) { - const { token, password, mfaCode } = req.body; - - if (!token || !password) { - this.logger.debug( - 'Request to change password failed because of missing user ID or password or reset password token in payload', - { - payload: req.body, - }, - ); - throw new BadRequestError('Missing user ID or password or reset password token'); - } - - const validPassword = this.passwordUtility.validate(password); + async changePassword( + req: AuthlessRequest, + res: Response, + @Body payload: ChangePasswordRequestDto, + ) { + const { token, password, mfaCode } = payload; const user = await this.authService.resolvePasswordResetToken(token); if (!user) throw new NotFoundError(''); @@ -198,7 +176,7 @@ export class PasswordResetController { if (!validToken) throw new BadRequestError('Invalid MFA token.'); } - const passwordHash = await this.passwordUtility.hash(validPassword); + const passwordHash = await this.passwordUtility.hash(password); await this.userService.update(user.id, { password: passwordHash }); diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index e290d294638f2..3177c2c23be63 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -11,8 +11,16 @@ import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { GlobalScope, Delete, Get, RestController, Patch, Licensed, Body } from '@/decorators'; -import { Param } from '@/decorators/args'; +import { + GlobalScope, + Delete, + Get, + RestController, + Patch, + Licensed, + Body, + Param, +} from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; diff --git a/packages/cli/src/decorators/index.ts b/packages/cli/src/decorators/index.ts index bd32add475d6e..8002bbe0940f9 100644 --- a/packages/cli/src/decorators/index.ts +++ b/packages/cli/src/decorators/index.ts @@ -1,4 +1,4 @@ -export { Body } from './args'; +export { Body, Query, Param } from './args'; export { RestController } from './rest-controller'; export { Get, Post, Put, Patch, Delete } from './route'; export { Middleware } from './middleware'; diff --git a/packages/cli/src/environments.ee/variables/variables.controller.ee.ts b/packages/cli/src/environments.ee/variables/variables.controller.ee.ts index a38906b800c26..460d5fa0093ed 100644 --- a/packages/cli/src/environments.ee/variables/variables.controller.ee.ts +++ b/packages/cli/src/environments.ee/variables/variables.controller.ee.ts @@ -1,7 +1,15 @@ import { VariableListRequestDto } from '@n8n/api-types'; -import { Delete, Get, GlobalScope, Licensed, Patch, Post, RestController } from '@/decorators'; -import { Query } from '@/decorators/args'; +import { + Delete, + Get, + GlobalScope, + Licensed, + Patch, + Post, + Query, + RestController, +} from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { VariableCountLimitReachedError } from '@/errors/variable-count-limit-reached.error'; diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index f7ac415a7547f..b49c46c7ffed3 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -1,7 +1,6 @@ import type { Scope } from '@n8n/permissions'; import type express from 'express'; import type { - BannerName, ICredentialDataDecryptedObject, IDataObject, ILoadOptions, @@ -19,7 +18,7 @@ import type { AssignableRole, GlobalRole, User } from '@/databases/entities/user import type { Variables } from '@/databases/entities/variables'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { WorkflowHistory } from '@/databases/entities/workflow-history'; -import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/interfaces'; +import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; import type { ProjectRole } from './databases/entities/project-relation'; import type { ScopesField } from './services/role.service'; @@ -195,42 +194,6 @@ export declare namespace MeRequest { export type SurveyAnswers = AuthenticatedRequest<{}, {}, IPersonalizationSurveyAnswersV4>; } -export interface UserSetupPayload { - email: string; - password: string; - firstName: string; - lastName: string; - mfaEnabled?: boolean; - mfaSecret?: string; - mfaRecoveryCodes?: string[]; -} - -// ---------------------------------- -// /owner -// ---------------------------------- - -export declare namespace OwnerRequest { - type Post = AuthenticatedRequest<{}, {}, UserSetupPayload, {}>; - - type DismissBanner = AuthenticatedRequest<{}, {}, Partial<{ bannerName: BannerName }>, {}>; -} - -// ---------------------------------- -// password reset endpoints -// ---------------------------------- - -export declare namespace PasswordResetRequest { - export type Email = AuthlessRequest<{}, {}, Pick>; - - export type Credentials = AuthlessRequest<{}, {}, {}, { userId?: string; token?: string }>; - - export type NewPassword = AuthlessRequest< - {}, - {}, - Pick & { token?: string; userId?: string; mfaCode?: string } - >; -} - // ---------------------------------- // /users // ---------------------------------- @@ -253,18 +216,6 @@ export declare namespace UserRequest { error?: string; }; - export type ResolveSignUp = AuthlessRequest< - {}, - {}, - {}, - { inviterId?: string; inviteeId?: string } - >; - - export type SignUp = AuthenticatedRequest< - { id: string }, - { inviterId?: string; inviteeId?: string } - >; - export type Delete = AuthenticatedRequest< { id: string; email: string; identifier: string }, {}, @@ -295,21 +246,6 @@ export declare namespace UserRequest { >; } -// ---------------------------------- -// /login -// ---------------------------------- - -export type LoginRequest = AuthlessRequest< - {}, - {}, - { - email: string; - password: string; - mfaCode?: string; - mfaRecoveryCode?: string; - } ->; - // ---------------------------------- // MFA endpoints // ---------------------------------- diff --git a/packages/cli/src/services/password.utility.ts b/packages/cli/src/services/password.utility.ts index 9719db44bb09f..6ae6aad61f8a2 100644 --- a/packages/cli/src/services/password.utility.ts +++ b/packages/cli/src/services/password.utility.ts @@ -19,6 +19,7 @@ export class PasswordUtility { return await compare(plaintext, hashed); } + /** @deprecated. All input validation should move to DTOs */ validate(plaintext?: string) { if (!plaintext) throw new BadRequestError('Password is mandatory'); diff --git a/packages/cli/test/integration/auth.api.test.ts b/packages/cli/test/integration/auth.api.test.ts index 6c1ddc5892011..4fa2a7145cbce 100644 --- a/packages/cli/test/integration/auth.api.test.ts +++ b/packages/cli/test/integration/auth.api.test.ts @@ -147,6 +147,21 @@ describe('POST /login', () => { const response = await testServer.authAgentFor(ownerUser).get('/login'); expect(response.statusCode).toBe(200); }); + + test('should fail on invalid email in the payload', async () => { + const response = await testServer.authlessAgent.post('/login').send({ + email: 'invalid-email', + password: ownerPassword, + }); + + expect(response.statusCode).toBe(400); + expect(response.body).toEqual({ + validation: 'email', + code: 'invalid_string', + message: 'Invalid email', + path: ['email'], + }); + }); }); describe('GET /login', () => { diff --git a/packages/cli/test/integration/mfa/mfa.api.test.ts b/packages/cli/test/integration/mfa/mfa.api.test.ts index 498be7abd53a0..f69d98a74fdcd 100644 --- a/packages/cli/test/integration/mfa/mfa.api.test.ts +++ b/packages/cli/test/integration/mfa/mfa.api.test.ts @@ -1,4 +1,4 @@ -import { randomInt, randomString } from 'n8n-workflow'; +import { randomString } from 'n8n-workflow'; import Container from 'typedi'; import { AuthService } from '@/auth/auth.service'; @@ -239,7 +239,7 @@ describe('Change password with MFA enabled', () => { .send({ password: newPassword, token: resetPasswordToken, - mfaCode: randomInt(10), + mfaCode: randomString(10), }) .expect(404); }); diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index a2a1e8e065c21..1f799a3fa168f 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -2,6 +2,7 @@ import type { Component } from 'vue'; import type { NotificationOptions as ElementNotificationOptions } from 'element-plus'; import type { Connection } from '@jsplumb/core'; import type { + BannerName, FrontendSettings, Iso8601DateTimeString, IUserManagementSettings, @@ -38,7 +39,6 @@ import type { ITelemetryTrackProperties, WorkflowSettings, IUserSettings, - BannerName, INodeExecutionData, INodeProperties, NodeConnectionType, diff --git a/packages/editor-ui/src/api/ui.ts b/packages/editor-ui/src/api/ui.ts index 5b27669e53b85..7716415c6afb9 100644 --- a/packages/editor-ui/src/api/ui.ts +++ b/packages/editor-ui/src/api/ui.ts @@ -1,6 +1,6 @@ import type { IRestApiContext } from '@/Interface'; import { makeRestApiRequest } from '@/utils/apiUtils'; -import type { BannerName } from 'n8n-workflow'; +import type { BannerName } from '@n8n/api-types'; export async function dismissBannerPermanently( context: IRestApiContext, diff --git a/packages/editor-ui/src/components/banners/BaseBanner.vue b/packages/editor-ui/src/components/banners/BaseBanner.vue index 6a0c4a343bb4f..aac7e3428e2e2 100644 --- a/packages/editor-ui/src/components/banners/BaseBanner.vue +++ b/packages/editor-ui/src/components/banners/BaseBanner.vue @@ -1,7 +1,7 @@ @@ -51,6 +53,7 @@ withDefaults(defineProps(), { :label="buttonText" :type="buttonType" :disabled="buttonDisabled" + :icon="buttonIcon" size="large" @click="$emit('click:button', $event)" /> diff --git a/packages/editor-ui/src/components/Logo/Logo.vue b/packages/editor-ui/src/components/Logo/Logo.vue index f10c168e28e22..6d643de718494 100644 --- a/packages/editor-ui/src/components/Logo/Logo.vue +++ b/packages/editor-ui/src/components/Logo/Logo.vue @@ -68,6 +68,7 @@ onMounted(() => {
{{ releaseChannel }}
+ diff --git a/packages/editor-ui/src/components/MainSidebar.vue b/packages/editor-ui/src/components/MainSidebar.vue index 40ace711e18f0..35f2d71f41120 100644 --- a/packages/editor-ui/src/components/MainSidebar.vue +++ b/packages/editor-ui/src/components/MainSidebar.vue @@ -10,6 +10,7 @@ import { useUIStore } from '@/stores/ui.store'; import { useUsersStore } from '@/stores/users.store'; import { useVersionsStore } from '@/stores/versions.store'; import { useWorkflowsStore } from '@/stores/workflows.store'; +import { useSourceControlStore } from '@/stores/sourceControl.store'; import { hasPermission } from '@/utils/rbac/permissions'; import { useDebounce } from '@/composables/useDebounce'; @@ -23,7 +24,7 @@ import { useBugReporting } from '@/composables/useBugReporting'; import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper'; import { useGlobalEntityCreation } from '@/composables/useGlobalEntityCreation'; -import { N8nNavigationDropdown } from 'n8n-design-system'; +import { N8nNavigationDropdown, N8nTooltip, N8nLink, N8nIconButton } from 'n8n-design-system'; import { onClickOutside, type VueInstance } from '@vueuse/core'; import Logo from './Logo/Logo.vue'; @@ -36,6 +37,7 @@ const uiStore = useUIStore(); const usersStore = useUsersStore(); const versionsStore = useVersionsStore(); const workflowsStore = useWorkflowsStore(); +const sourceControlStore = useSourceControlStore(); const { callDebounced } = useDebounce(); const externalHooks = useExternalHooks(); @@ -292,6 +294,8 @@ const { menu, handleSelect: handleMenuSelect, createProjectAppendSlotName, + createWorkflowsAppendSlotName, + createCredentialsAppendSlotName, projectsLimitReachedMessage, upgradeLabel, } = useGlobalEntityCreation(); @@ -322,7 +326,26 @@ onClickOutside(createBtn as Ref, () => { location="sidebar" :collapsed="isCollapsed" :release-channel="settingsStore.settings.releaseChannel" - /> + > + + + + + , () => { @select="handleMenuSelect" > + + diff --git a/packages/editor-ui/src/components/Projects/ProjectHeader.vue b/packages/editor-ui/src/components/Projects/ProjectHeader.vue index 8ef45239fcf91..2e7ce76d70a96 100644 --- a/packages/editor-ui/src/components/Projects/ProjectHeader.vue +++ b/packages/editor-ui/src/components/Projects/ProjectHeader.vue @@ -1,7 +1,7 @@ + + + + diff --git a/packages/design-system/src/components/N8nIconPicker/constants.ts b/packages/design-system/src/components/N8nIconPicker/constants.ts new file mode 100644 index 0000000000000..ca62c037732ab --- /dev/null +++ b/packages/design-system/src/components/N8nIconPicker/constants.ts @@ -0,0 +1,163 @@ +export const TEST_ICONS = [ + 'angle-double-left', + 'angle-down', + 'angle-left', + 'angle-right', + 'angle-up', + 'archive', + 'arrow-left', + 'arrow-right', + 'arrow-up', + 'arrow-down', + 'at', + 'ban', + 'balance-scale-left', + 'bars', + 'bolt', + 'book', + 'box-open', + 'bug', + 'brain', + 'calculator', + 'calendar', + 'chart-bar', + 'check', + 'check-circle', + 'check-square', + 'chevron-left', + 'chevron-right', + 'chevron-down', + 'chevron-up', + 'code', + 'code-branch', + 'cog', + 'cogs', + 'comment', + 'comments', + 'clipboard-list', + 'clock', + 'clone', + 'cloud', + 'cloud-download-alt', + 'copy', + 'cube', + 'cut', + 'database', + 'dot-circle', + 'grip-lines-vertical', + 'grip-vertical', + 'edit', + 'ellipsis-h', + 'ellipsis-v', + 'envelope', + 'equals', + 'eye', + 'exclamation-triangle', + 'expand', + 'expand-alt', + 'external-link-alt', + 'exchange-alt', + 'file', + 'file-alt', + 'file-archive', + 'file-code', + 'file-download', + 'file-export', + 'file-import', + 'file-pdf', + 'filter', + 'fingerprint', + 'flask', + 'folder-open', + 'font', + 'gift', + 'globe', + 'globe-americas', + 'graduation-cap', + 'hand-holding-usd', + 'hand-scissors', + 'handshake', + 'hand-point-left', + 'hashtag', + 'hdd', + 'history', + 'home', + 'hourglass', + 'image', + 'inbox', + 'info', + 'info-circle', + 'key', + 'language', + 'layer-group', + 'link', + 'list', + 'lightbulb', + 'lock', + 'map-signs', + 'mouse-pointer', + 'network-wired', + 'palette', + 'pause', + 'pause-circle', + 'pen', + 'pencil-alt', + 'play', + 'play-circle', + 'plug', + 'plus', + 'plus-circle', + 'plus-square', + 'project-diagram', + 'question', + 'question-circle', + 'redo', + 'remove-format', + 'robot', + 'rss', + 'save', + 'satellite-dish', + 'search', + 'search-minus', + 'search-plus', + 'server', + 'screwdriver', + 'smile', + 'sign-in-alt', + 'sign-out-alt', + 'sliders-h', + 'spinner', + 'sticky-note', + 'stop', + 'stream', + 'sun', + 'sync', + 'sync-alt', + 'table', + 'tags', + 'tasks', + 'terminal', + 'th-large', + 'thumbtack', + 'thumbs-down', + 'thumbs-up', + 'times', + 'times-circle', + 'toolbox', + 'tools', + 'trash', + 'undo', + 'unlink', + 'user', + 'user-circle', + 'user-friends', + 'users', + 'vector-square', + 'video', + 'tree', + 'user-lock', + 'gem', + 'download', + 'power-off', + 'paper-plane', +]; diff --git a/packages/design-system/src/components/N8nIconPicker/index.ts b/packages/design-system/src/components/N8nIconPicker/index.ts new file mode 100644 index 0000000000000..5045eca16276e --- /dev/null +++ b/packages/design-system/src/components/N8nIconPicker/index.ts @@ -0,0 +1,2 @@ +import IconPicker from './IconPicker.vue'; +export default IconPicker; diff --git a/packages/design-system/src/components/N8nMenuItem/MenuItem.vue b/packages/design-system/src/components/N8nMenuItem/MenuItem.vue index e9a34c7e04304..f22bcd88276de 100644 --- a/packages/design-system/src/components/N8nMenuItem/MenuItem.vue +++ b/packages/design-system/src/components/N8nMenuItem/MenuItem.vue @@ -123,12 +123,17 @@ const isItemActive = (item: IMenuItem): boolean => { :disabled="item.disabled" @click="handleSelect?.(item)" > - +
+ + {{ + item.icon.value + }} +
{{ item.label }} {{ getInitials(item.label) diff --git a/packages/design-system/src/components/index.ts b/packages/design-system/src/components/index.ts index 2d06e5b8c6c73..38484308ef5e1 100644 --- a/packages/design-system/src/components/index.ts +++ b/packages/design-system/src/components/index.ts @@ -54,3 +54,4 @@ export { default as N8nUserSelect } from './N8nUserSelect'; export { default as N8nUsersList } from './N8nUsersList'; export { default as N8nResizeObserver } from './ResizeObserver'; export { N8nKeyboardShortcut } from './N8nKeyboardShortcut'; +export { default as N8nIconPicker } from './N8nIconPicker'; diff --git a/packages/design-system/src/locale/lang/en.ts b/packages/design-system/src/locale/lang/en.ts index 9e2e141b175b3..35f2fd9f0e5de 100644 --- a/packages/design-system/src/locale/lang/en.ts +++ b/packages/design-system/src/locale/lang/en.ts @@ -48,4 +48,7 @@ export default { 'assistantChat.copy': 'Copy', 'assistantChat.copied': 'Copied', 'inlineAskAssistantButton.asked': 'Asked', + 'iconPicker.button.defaultToolTip': 'Choose icon', + 'iconPicker.tabs.icons': 'Icons', + 'iconPicker.tabs.emojis': 'Emojis', } as N8nLocale; diff --git a/packages/design-system/src/types/menu.ts b/packages/design-system/src/types/menu.ts index 258ff7d5554ad..c042489586bb1 100644 --- a/packages/design-system/src/types/menu.ts +++ b/packages/design-system/src/types/menu.ts @@ -5,7 +5,7 @@ import type { RouteLocationRaw, RouterLinkProps } from 'vue-router'; export type IMenuItem = { id: string; label: string; - icon?: string; + icon?: string | { type: 'icon' | 'emoji'; value: string }; secondaryIcon?: { name: string; size?: 'xsmall' | 'small' | 'medium' | 'large'; diff --git a/packages/editor-ui/src/__tests__/data/projects.ts b/packages/editor-ui/src/__tests__/data/projects.ts index 98878c339b34c..d7c26b245e62d 100644 --- a/packages/editor-ui/src/__tests__/data/projects.ts +++ b/packages/editor-ui/src/__tests__/data/projects.ts @@ -10,6 +10,7 @@ import { ProjectTypes } from '@/types/projects.types'; export const createProjectSharingData = (projectType?: ProjectType): ProjectSharingData => ({ id: faker.string.uuid(), name: faker.lorem.words({ min: 1, max: 3 }), + icon: { type: 'icon', value: 'folder' }, type: projectType ?? ProjectTypes.Personal, createdAt: faker.date.past().toISOString(), updatedAt: faker.date.recent().toISOString(), @@ -29,6 +30,7 @@ export function createTestProject(data: Partial): Project { return { id: faker.string.uuid(), name: faker.lorem.words({ min: 1, max: 3 }), + icon: { type: 'icon', value: 'folder' }, createdAt: faker.date.past().toISOString(), updatedAt: faker.date.recent().toISOString(), type: ProjectTypes.Team, diff --git a/packages/editor-ui/src/api/projects.api.ts b/packages/editor-ui/src/api/projects.api.ts index b3bae3fbf1564..325feefc63b17 100644 --- a/packages/editor-ui/src/api/projects.api.ts +++ b/packages/editor-ui/src/api/projects.api.ts @@ -37,8 +37,8 @@ export const updateProject = async ( context: IRestApiContext, req: ProjectUpdateRequest, ): Promise => { - const { id, name, relations } = req; - await makeRestApiRequest(context, 'PATCH', `/projects/${id}`, { name, relations }); + const { id, name, icon, relations } = req; + await makeRestApiRequest(context, 'PATCH', `/projects/${id}`, { name, icon, relations }); }; export const deleteProject = async ( diff --git a/packages/editor-ui/src/components/Projects/ProjectHeader.vue b/packages/editor-ui/src/components/Projects/ProjectHeader.vue index 2e7ce76d70a96..191c7d7dd5e00 100644 --- a/packages/editor-ui/src/components/Projects/ProjectHeader.vue +++ b/packages/editor-ui/src/components/Projects/ProjectHeader.vue @@ -3,7 +3,7 @@ import { computed } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import { N8nButton, N8nTooltip } from 'n8n-design-system'; import { useI18n } from '@/composables/useI18n'; -import { ProjectTypes } from '@/types/projects.types'; +import { type ProjectIcon, ProjectTypes } from '@/types/projects.types'; import { useProjectsStore } from '@/stores/projects.store'; import ProjectTabs from '@/components/Projects/ProjectTabs.vue'; import { getResourcePermissions } from '@/permissions'; @@ -17,13 +17,13 @@ const i18n = useI18n(); const projectsStore = useProjectsStore(); const sourceControlStore = useSourceControlStore(); -const headerIcon = computed(() => { +const headerIcon = computed((): ProjectIcon => { if (projectsStore.currentProject?.type === ProjectTypes.Personal) { - return 'user'; + return { type: 'icon', value: 'user' }; } else if (projectsStore.currentProject?.name) { - return 'layer-group'; + return projectsStore.currentProject.icon ?? { type: 'icon', value: 'layer-group' }; } else { - return 'home'; + return { type: 'icon', value: 'home' }; } }); @@ -107,9 +107,7 @@ const onSelect = (action: string) => {