refactor(core): Enable import/order eslint rule (#10794)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run

This commit is contained in:
Tomi Turtiainen 2024-09-12 19:07:18 +03:00 committed by GitHub
parent 6530620e9d
commit 5156313074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
569 changed files with 3019 additions and 2523 deletions

View file

@ -28,7 +28,17 @@ module.exports = {
// TODO: Remove this
'import/no-cycle': 'warn',
'import/order': 'off',
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
groups: [['builtin', 'external'], 'internal', ['parent', 'index', 'sibling'], 'object'],
'newlines-between': 'always',
},
],
'import/extensions': 'warn',
'@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }],
'@typescript-eslint/no-explicit-any': 'warn',

View file

@ -1,15 +1,16 @@
import { ActiveExecutions } from '@/active-executions';
import PCancelable from 'p-cancelable';
import { v4 as uuid } from 'uuid';
import { mock } from 'jest-mock-extended';
import type {
IExecuteResponsePromiseData,
IRun,
IWorkflowExecutionDataProcess,
} from 'n8n-workflow';
import { createDeferredPromise } from 'n8n-workflow';
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { mock } from 'jest-mock-extended';
import PCancelable from 'p-cancelable';
import { v4 as uuid } from 'uuid';
import { ActiveExecutions } from '@/active-executions';
import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service';
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { mockInstance } from '@test/mocking';
const FAKE_EXECUTION_ID = '15';

View file

@ -1,5 +1,6 @@
import { CredentialTypes } from '@/credential-types';
import { Container } from 'typedi';
import { CredentialTypes } from '@/credential-types';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import { mockInstance } from '@test/mocking';

View file

@ -1,4 +1,3 @@
import Container from 'typedi';
import type {
IAuthenticateGeneric,
ICredentialDataDecryptedObject,
@ -9,11 +8,13 @@ import type {
} from 'n8n-workflow';
import { NodeConnectionType, deepCopy } from 'n8n-workflow';
import { Workflow } from 'n8n-workflow';
import Container from 'typedi';
import { CredentialsHelper } from '@/credentials-helper';
import { NodeTypes } from '@/node-types';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import { NodeTypes } from '@/node-types';
import { mockInstance } from '@test/mocking';
describe('CredentialsHelper', () => {

View file

@ -1,12 +1,13 @@
import { LicenseManager } from '@n8n_io/license-sdk';
import { InstanceSettings } from 'n8n-core';
import { mock } from 'jest-mock-extended';
import { InstanceSettings } from 'n8n-core';
import config from '@/config';
import { N8N_VERSION } from '@/constants';
import { License } from '@/license';
import { Logger } from '@/logger';
import { N8N_VERSION } from '@/constants';
import { mockInstance } from '@test/mocking';
import { OrchestrationService } from '@/services/orchestration.service';
import { mockInstance } from '@test/mocking';
jest.mock('@n8n_io/license-sdk');

View file

@ -1,9 +1,10 @@
import { WaitTracker } from '@/wait-tracker';
import { mock } from 'jest-mock-extended';
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
import type { IExecutionResponse } from '@/interfaces';
import { OrchestrationService } from '@/services/orchestration.service';
import type { MultiMainSetup } from '@/services/orchestration/main/multi-main-setup.ee';
import { OrchestrationService } from '@/services/orchestration.service';
import { WaitTracker } from '@/wait-tracker';
jest.useFakeTimers();

View file

@ -1,10 +1,11 @@
import { VariablesService } from '@/environments/variables/variables.service.ee';
import { mockInstance } from '@test/mocking';
import { getBase } from '@/workflow-execute-additional-data';
import Container from 'typedi';
import { CredentialsHelper } from '@/credentials-helper';
import { SecretsHelper } from '@/secrets-helpers';
import { VariablesService } from '@/environments/variables/variables.service.ee';
import { EventService } from '@/events/event.service';
import { SecretsHelper } from '@/secrets-helpers';
import { getBase } from '@/workflow-execute-additional-data';
import { mockInstance } from '@test/mocking';
describe('WorkflowExecuteAdditionalData', () => {
const variablesService = mockInstance(VariablesService);

View file

@ -1,4 +1,5 @@
import type { Workflow, IWorkflowExecutionDataProcess } from 'n8n-workflow';
import { getExecutionStartNode } from '@/workflow-helpers';
describe('WorkflowHelpers', () => {

View file

@ -1,16 +1,16 @@
import Container from 'typedi';
import { WorkflowHooks, type ExecutionError, type IWorkflowExecuteHooks } from 'n8n-workflow';
import type { User } from '@/databases/entities/user';
import { WorkflowRunner } from '@/workflow-runner';
import config from '@/config';
import Container from 'typedi';
import * as testDb from '@test-integration/test-db';
import { setupTestServer } from '@test-integration/utils';
import config from '@/config';
import type { User } from '@/databases/entities/user';
import { Telemetry } from '@/telemetry';
import { WorkflowRunner } from '@/workflow-runner';
import { mockInstance } from '@test/mocking';
import { createExecution } from '@test-integration/db/executions';
import { createUser } from '@test-integration/db/users';
import { createWorkflow } from '@test-integration/db/workflows';
import { createExecution } from '@test-integration/db/executions';
import { mockInstance } from '@test/mocking';
import { Telemetry } from '@/telemetry';
import * as testDb from '@test-integration/test-db';
import { setupTestServer } from '@test-integration/utils';
let owner: User;
let runner: WorkflowRunner;

View file

@ -1,28 +1,29 @@
import { Container, Service } from 'typedi';
import { readFile } from 'fs/promises';
import type { Server } from 'http';
import { GlobalConfig } from '@n8n/config';
import compression from 'compression';
import express from 'express';
import { engine as expressHandlebars } from 'express-handlebars';
import compression from 'compression';
import { readFile } from 'fs/promises';
import type { Server } from 'http';
import isbot from 'isbot';
import { Container, Service } from 'typedi';
import config from '@/config';
import { N8N_VERSION, TEMPLATES_DIR, inDevelopment, inTest } from '@/constants';
import * as Db from '@/db';
import { N8nInstanceType } from '@/interfaces';
import { OnShutdown } from '@/decorators/on-shutdown';
import { ExternalHooks } from '@/external-hooks';
import { send, sendErrorResponse } from '@/response-helper';
import { N8nInstanceType } from '@/interfaces';
import { Logger } from '@/logger';
import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares';
import { send, sendErrorResponse } from '@/response-helper';
import { WaitingForms } from '@/waiting-forms';
import { LiveWebhooks } from '@/webhooks/live-webhooks';
import { TestWebhooks } from '@/webhooks/test-webhooks';
import { WaitingWebhooks } from '@/webhooks/waiting-webhooks';
import { createWebhookHandlerFor } from '@/webhooks/webhook-request-handler';
import { LiveWebhooks } from '@/webhooks/live-webhooks';
import { generateHostInstanceId } from './databases/utils/generators';
import { Logger } from '@/logger';
import { ServiceUnavailableError } from './errors/response-errors/service-unavailable.error';
import { OnShutdown } from '@/decorators/on-shutdown';
import { GlobalConfig } from '@n8n/config';
@Service()
export abstract class AbstractServer {

View file

@ -1,4 +1,5 @@
import { Service } from 'typedi';
import { CacheService } from '@/services/cache/cache.service';
@Service()

View file

@ -1,5 +1,3 @@
import { Service } from 'typedi';
import type PCancelable from 'p-cancelable';
import type {
IDeferredPromise,
IExecuteResponsePromiseData,
@ -14,16 +12,19 @@ import {
sleep,
} from 'n8n-workflow';
import { strict as assert } from 'node:assert';
import type PCancelable from 'p-cancelable';
import { Service } from 'typedi';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import type {
ExecutionPayload,
IExecutingWorkflowData,
IExecutionDb,
IExecutionsCurrentSummary,
} from '@/interfaces';
import { isWorkflowIdValid } from '@/utils';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { Logger } from '@/logger';
import { isWorkflowIdValid } from '@/utils';
import { ConcurrencyControlService } from './concurrency/concurrency-control.service';
import config from './config';

View file

@ -1,8 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { Service } from 'typedi';
import { ActiveWorkflows, NodeExecuteFunctions } from 'n8n-core';
import type {
ExecutionError,
IDeferredPromise,
@ -25,30 +23,31 @@ import {
WebhookPathTakenError,
ApplicationError,
} from 'n8n-workflow';
import { Service } from 'typedi';
import type { IWorkflowDb } from '@/interfaces';
import * as WebhookHelpers from '@/webhooks/webhook-helpers';
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
import { ActivationErrorsService } from '@/activation-errors.service';
import { ActiveExecutions } from '@/active-executions';
import { ExecutionService } from './executions/execution.service';
import {
STARTING_NODES,
WORKFLOW_REACTIVATE_INITIAL_TIMEOUT,
WORKFLOW_REACTIVATE_MAX_TIMEOUT,
} from '@/constants';
import { NodeTypes } from '@/node-types';
import { ExternalHooks } from '@/external-hooks';
import { WebhookService } from '@/webhooks/webhook.service';
import { Logger } from './logger';
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { OrchestrationService } from '@/services/orchestration.service';
import { ActivationErrorsService } from '@/activation-errors.service';
import { OnShutdown } from '@/decorators/on-shutdown';
import { ExternalHooks } from '@/external-hooks';
import type { IWorkflowDb } from '@/interfaces';
import { NodeTypes } from '@/node-types';
import { ActiveWorkflowsService } from '@/services/active-workflows.service';
import { OrchestrationService } from '@/services/orchestration.service';
import * as WebhookHelpers from '@/webhooks/webhook-helpers';
import { WebhookService } from '@/webhooks/webhook.service';
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
import { WorkflowExecutionService } from '@/workflows/workflow-execution.service';
import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service';
import { OnShutdown } from '@/decorators/on-shutdown';
import { ExecutionService } from './executions/execution.service';
import { Logger } from './logger';
interface QueuedActivation {
activationMode: WorkflowActivateMode;

View file

@ -1,6 +1,6 @@
import jwt from 'jsonwebtoken';
import { mock } from 'jest-mock-extended';
import type { NextFunction, Response } from 'express';
import { mock } from 'jest-mock-extended';
import jwt from 'jsonwebtoken';
import { AuthService } from '@/auth/auth.service';
import config from '@/config';
@ -8,9 +8,9 @@ import { AUTH_COOKIE_NAME, Time } from '@/constants';
import type { User } from '@/databases/entities/user';
import type { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository';
import type { UserRepository } from '@/databases/repositories/user.repository';
import type { AuthenticatedRequest } from '@/requests';
import { JwtService } from '@/services/jwt.service';
import type { UrlService } from '@/services/url.service';
import type { AuthenticatedRequest } from '@/requests';
describe('AuthService', () => {
config.set('userManagement.jwtSecret', 'random-secret');

View file

@ -1,7 +1,8 @@
import Container, { Service } from 'typedi';
import type { NextFunction, Response } from 'express';
import { GlobalConfig } from '@n8n/config';
import { createHash } from 'crypto';
import type { NextFunction, Response } from 'express';
import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken';
import Container, { Service } from 'typedi';
import config from '@/config';
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
@ -15,7 +16,6 @@ import { Logger } from '@/logger';
import type { AuthenticatedRequest } from '@/requests';
import { JwtService } from '@/services/jwt.service';
import { UrlService } from '@/services/url.service';
import { GlobalConfig } from '@n8n/config';
interface AuthJwtPayload {
/** User Id */

View file

@ -1,7 +1,8 @@
import { Container } from 'typedi';
import type { Response } from 'express';
import { Container } from 'typedi';
import type { User } from '@/databases/entities/user';
import { AuthService } from './auth.service';
// This method is still used by cloud hooks.

View file

@ -1,10 +1,11 @@
import type { User } from '@/databases/entities/user';
import { PasswordUtility } from '@/services/password.utility';
import { Container } from 'typedi';
import { isLdapLoginEnabled } from '@/ldap/helpers.ee';
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 { PasswordUtility } from '@/services/password.utility';
export const handleEmailLogin = async (
email: string,

View file

@ -1,6 +1,7 @@
import { Container } from 'typedi';
import { LdapService } from '@/ldap/ldap.service.ee';
import type { User } from '@/databases/entities/user';
import { EventService } from '@/events/event.service';
import {
createLdapUserOnLocalDb,
getUserByEmail,
@ -10,8 +11,7 @@ import {
createLdapAuthIdentity,
updateLdapUserOnLocalDb,
} from '@/ldap/helpers.ee';
import type { User } from '@/databases/entities/user';
import { EventService } from '@/events/event.service';
import { LdapService } from '@/ldap/ldap.service.ee';
export const handleLdapLogin = async (
loginId: string,

View file

@ -1,7 +1,9 @@
import { CollaborationState } from '../collaboration.state';
import type { CacheService } from '@/services/cache/cache.service';
import { mock } from 'jest-mock-extended';
import type { CacheService } from '@/services/cache/cache.service';
import { CollaborationState } from '../collaboration.state';
const origDate = global.Date;
const mockDateFactory = (currentDate: string) => {

View file

@ -1,13 +1,13 @@
import { Service } from 'typedi';
import type { Workflow } from 'n8n-workflow';
import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow';
import { Service } from 'typedi';
import { Push } from '@/push';
import type { ICollaboratorsChanged } from '@/interfaces';
import type { OnPushMessage } from '@/push/types';
import { UserRepository } from '@/databases/repositories/user.repository';
import type { User } from '@/databases/entities/user';
import { CollaborationState } from '@/collaboration/collaboration.state';
import type { User } from '@/databases/entities/user';
import { UserRepository } from '@/databases/repositories/user.repository';
import type { ICollaboratorsChanged } from '@/interfaces';
import { Push } from '@/push';
import type { OnPushMessage } from '@/push/types';
import { AccessService } from '@/services/access.service';
import type { WorkflowClosedMessage, WorkflowOpenedMessage } from './collaboration.message';

View file

@ -1,10 +1,10 @@
import { Service } from 'typedi';
import type { Workflow } from 'n8n-workflow';
import { Service } from 'typedi';
import { Time } from '@/constants';
import type { User } from '@/databases/entities/user';
import type { Iso8601DateTimeString } from '@/interfaces';
import { CacheService } from '@/services/cache/cache.service';
import type { User } from '@/databases/entities/user';
type WorkflowCacheHash = Record<User['id'], Iso8601DateTimeString>;
interface CacheEntry {

View file

@ -1,11 +1,12 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { ApplicationError } from 'n8n-workflow';
import { Container } from 'typedi';
import { SecurityAuditService } from '@/security-audit/security-audit.service';
import { RISK_CATEGORIES } from '@/security-audit/constants';
import config from '@/config';
import { RISK_CATEGORIES } from '@/security-audit/constants';
import { SecurityAuditService } from '@/security-audit/security-audit.service';
import type { Risk } from '@/security-audit/types';
import { BaseCommand } from './base-command';
export class SecurityAudit extends BaseCommand {

View file

@ -1,29 +1,30 @@
import 'reflect-metadata';
import { Container } from 'typedi';
import { Command, Errors } from '@oclif/core';
import { GlobalConfig } from '@n8n/config';
import { ApplicationError, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
import { Command, Errors } from '@oclif/core';
import { BinaryDataService, InstanceSettings, ObjectStoreService } from 'n8n-core';
import { ApplicationError, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
import { Container } from 'typedi';
import type { AbstractServer } from '@/abstract-server';
import { Logger } from '@/logger';
import config from '@/config';
import * as Db from '@/db';
import * as CrashJournal from '@/crash-journal';
import { LICENSE_FEATURES, inDevelopment, inTest } from '@/constants';
import { initErrorHandling } from '@/error-reporting';
import { ExternalHooks } from '@/external-hooks';
import { NodeTypes } from '@/node-types';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import type { N8nInstanceType } from '@/interfaces';
import { PostHogClient } from '@/posthog';
import { License } from '@/license';
import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee';
import { initExpressionEvaluator } from '@/expression-evaluator';
import * as CrashJournal from '@/crash-journal';
import { generateHostInstanceId } from '@/databases/utils/generators';
import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee';
import { ShutdownService } from '@/shutdown/shutdown.service';
import { TelemetryEventRelay } from '@/events/telemetry-event-relay';
import * as Db from '@/db';
import { initErrorHandling } from '@/error-reporting';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import { TelemetryEventRelay } from '@/events/telemetry-event-relay';
import { initExpressionEvaluator } from '@/expression-evaluator';
import { ExternalHooks } from '@/external-hooks';
import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee';
import type { N8nInstanceType } from '@/interfaces';
import { License } from '@/license';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
import { Logger } from '@/logger';
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';
export abstract class BaseCommand extends Command {
protected logger = Container.get(Logger);

View file

@ -1,11 +1,12 @@
import { main } from '@/commands/db/revert';
import { mockInstance } from '@test/mocking';
import { Logger } from '@/logger';
import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types';
import type { Migration, MigrationExecutor } from '@n8n/typeorm';
import { type DataSource } from '@n8n/typeorm';
import { mock } from 'jest-mock-extended';
import { main } from '@/commands/db/revert';
import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types';
import { Logger } from '@/logger';
import { mockInstance } from '@test/mocking';
const logger = mockInstance(Logger);
afterEach(() => {

View file

@ -1,13 +1,14 @@
import { Command, Flags } from '@oclif/core';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
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 { Container } from 'typedi';
import { Logger } from '@/logger';
import { getConnectionOptions } from '@/databases/config';
import type { Migration } from '@/databases/types';
import { wrapMigration } from '@/databases/utils/migration-helpers';
import { Logger } from '@/logger';
// 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

View file

@ -1,21 +1,21 @@
/* eslint-disable @typescript-eslint/no-loop-func */
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import fs from 'fs';
import os from 'os';
import type { IRun, ITaskData, IWorkflowExecutionDataProcess } from 'n8n-workflow';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import { sep } from 'path';
import { diff } from 'json-diff';
import pick from 'lodash/pick';
import type { IRun, ITaskData, IWorkflowExecutionDataProcess } from 'n8n-workflow';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import os from 'os';
import { sep } from 'path';
import { Container } from 'typedi';
import { ActiveExecutions } from '@/active-executions';
import { WorkflowRunner } from '@/workflow-runner';
import type { IWorkflowDb } from '@/interfaces';
import type { User } from '@/databases/entities/user';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import type { IWorkflowDb } from '@/interfaces';
import { OwnershipService } from '@/services/ownership.service';
import { findCliWorkflowStart } from '@/utils';
import { WorkflowRunner } from '@/workflow-runner';
import { BaseCommand } from './base-command';
import type {

View file

@ -1,15 +1,15 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import type { IWorkflowBase, IWorkflowExecutionDataProcess } from 'n8n-workflow';
import { ApplicationError, ExecutionBaseError } from 'n8n-workflow';
import { Container } from 'typedi';
import { ActiveExecutions } from '@/active-executions';
import { WorkflowRunner } from '@/workflow-runner';
import { findCliWorkflowStart, isWorkflowIdValid } from '@/utils';
import { BaseCommand } from './base-command';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { OwnershipService } from '@/services/ownership.service';
import { findCliWorkflowStart, isWorkflowIdValid } from '@/utils';
import { WorkflowRunner } from '@/workflow-runner';
import { BaseCommand } from './base-command';
export class Execute extends BaseCommand {
static description = '\nExecutes a given workflow';

View file

@ -1,12 +1,14 @@
import { Flags } from '@oclif/core';
import fs from 'fs';
import path from 'path';
import { Credentials } from 'n8n-core';
import type { ICredentialsDb, ICredentialsDecryptedDb } from '@/interfaces';
import { BaseCommand } from '../base-command';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import Container from 'typedi';
import { ApplicationError } from 'n8n-workflow';
import path from 'path';
import Container from 'typedi';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import type { ICredentialsDb, ICredentialsDecryptedDb } from '@/interfaces';
import { BaseCommand } from '../base-command';
export class ExportCredentialsCommand extends BaseCommand {
static description = 'Export credentials';

View file

@ -1,10 +1,12 @@
import { Flags } from '@oclif/core';
import fs from 'fs';
import path from 'path';
import { BaseCommand } from '../base-command';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import Container from 'typedi';
import { ApplicationError } from 'n8n-workflow';
import path from 'path';
import Container from 'typedi';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { BaseCommand } from '../base-command';
export class ExportWorkflowsCommand extends BaseCommand {
static description = 'Export workflows';

View file

@ -1,21 +1,22 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { Cipher } from 'n8n-core';
import fs from 'fs';
import glob from 'fast-glob';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import type { EntityManager } from '@n8n/typeorm';
import * as Db from '@/db';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { BaseCommand } from '../base-command';
import { Flags } from '@oclif/core';
import glob from 'fast-glob';
import fs from 'fs';
import { Cipher } from 'n8n-core';
import type { ICredentialsEncrypted } from 'n8n-workflow';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import { Container } from 'typedi';
import { UM_FIX_INSTRUCTION } from '@/constants';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { Project } from '@/databases/entities/project';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import { User } from '@/databases/entities/user';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import * as Db from '@/db';
import { BaseCommand } from '../base-command';
export class ImportCredentialsCommand extends BaseCommand {
static description = 'Import credentials';

View file

@ -1,19 +1,20 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import fs from 'fs';
import glob from 'fast-glob';
import fs from 'fs';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import { Container } from 'typedi';
import { UM_FIX_INSTRUCTION } from '@/constants';
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
import { generateNanoId } from '@/databases/utils/generators';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { generateNanoId } from '@/databases/utils/generators';
import type { IWorkflowToImport } from '@/interfaces';
import { ImportService } from '@/services/import.service';
import { BaseCommand } from '../base-command';
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
import { ProjectRepository } from '@/databases/repositories/project.repository';
function assertHasWorkflowsToImport(workflows: unknown): asserts workflows is IWorkflowToImport[] {
if (!Array.isArray(workflows)) {

View file

@ -1,21 +1,23 @@
import Container from 'typedi';
import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants';
import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository';
import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { BaseCommand } from '../base-command';
import { Flags } from '@oclif/core';
import { ApplicationError } from 'n8n-workflow';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { WorkflowService } from '@/workflows/workflow.service';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In } from '@n8n/typeorm';
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
import { CredentialsService } from '@/credentials/credentials.service';
import { Flags } from '@oclif/core';
import { ApplicationError } from 'n8n-workflow';
import Container from 'typedi';
import { UM_FIX_INSTRUCTION } from '@/constants';
import { CredentialsService } from '@/credentials/credentials.service';
import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository';
import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository';
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
import { ProjectRepository } from '@/databases/repositories/project.repository';
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 { WorkflowService } from '@/workflows/workflow.service';
import { BaseCommand } from '../base-command';
const wrongFlagsError =
'You must use exactly one of `--userId`, `--projectId` or `--deleteWorkflowsAndCredentials`.';

View file

@ -1,9 +1,11 @@
import { Container } from 'typedi';
import { SETTINGS_LICENSE_CERT_KEY } from '@/constants';
import { BaseCommand } from '../base-command';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { License } from '@/license';
import { BaseCommand } from '../base-command';
export class ClearLicenseCommand extends BaseCommand {
static description = 'Clear license';

View file

@ -1,5 +1,7 @@
import { Container } from 'typedi';
import { License } from '@/license';
import { BaseCommand } from '../base-command';
export class LicenseInfoCommand extends BaseCommand {

View file

@ -1,6 +1,8 @@
import Container from 'typedi';
import { Flags } from '@oclif/core';
import Container from 'typedi';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { BaseCommand } from '../base-command';
export class ListWorkflowCommand extends BaseCommand {

View file

@ -1,6 +1,8 @@
import Container from 'typedi';
import { Flags } from '@oclif/core';
import Container from 'typedi';
import { AuthUserRepository } from '@/databases/repositories/auth-user.repository';
import { BaseCommand } from '../base-command';
export class DisableMFACommand extends BaseCommand {

View file

@ -1,35 +1,36 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import path from 'path';
import { mkdir } from 'fs/promises';
import { createReadStream, createWriteStream, existsSync } from 'fs';
import { pipeline } from 'stream/promises';
import replaceStream from 'replacestream';
import glob from 'fast-glob';
import { createReadStream, createWriteStream, existsSync } from 'fs';
import { mkdir } from 'fs/promises';
import { jsonParse, randomString, type IWorkflowExecutionDataProcess } from 'n8n-workflow';
import path from 'path';
import replaceStream from 'replacestream';
import { pipeline } from 'stream/promises';
import { Container } from 'typedi';
import config from '@/config';
import { ActiveExecutions } from '@/active-executions';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import { Server } from '@/server';
import config from '@/config';
import { EDITOR_UI_DIST_DIR, LICENSE_FEATURES } from '@/constants';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import { EventService } from '@/events/event.service';
import { ExecutionService } from '@/executions/execution.service';
import { License } from '@/license';
import { OrchestrationService } from '@/services/orchestration.service';
import { Server } from '@/server';
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
import { OrchestrationService } from '@/services/orchestration.service';
import { OwnershipService } from '@/services/ownership.service';
import { PruningService } from '@/services/pruning.service';
import { UrlService } from '@/services/url.service';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error';
import { WaitTracker } from '@/wait-tracker';
import { BaseCommand } from './base-command';
import { ExecutionService } from '@/executions/execution.service';
import { OwnershipService } from '@/services/ownership.service';
import { WorkflowRunner } from '@/workflow-runner';
import { EventService } from '@/events/event.service';
import { BaseCommand } from './base-command';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const open = require('open');

View file

@ -1,6 +1,8 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { Container } from 'typedi';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { BaseCommand } from '../base-command';
export class UpdateWorkflowCommand extends BaseCommand {

View file

@ -1,13 +1,15 @@
import { Container } from 'typedi';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { User } from '@/databases/entities/user';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { ProjectRepository } from '@/databases/repositories/project.repository';
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 { BaseCommand } from '../base-command';
import { ProjectRepository } from '@/databases/repositories/project.repository';
const defaultUserProps = {
firstName: null,

View file

@ -1,14 +1,14 @@
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import { ApplicationError } from 'n8n-workflow';
import { Container } from 'typedi';
import config from '@/config';
import { ActiveExecutions } from '@/active-executions';
import { WebhookServer } from '@/webhooks/webhook-server';
import { BaseCommand } from './base-command';
import { OrchestrationWebhookService } from '@/services/orchestration/webhook/orchestration.webhook.service';
import config from '@/config';
import { OrchestrationHandlerWebhookService } from '@/services/orchestration/webhook/orchestration.handler.webhook.service';
import { OrchestrationWebhookService } from '@/services/orchestration/webhook/orchestration.webhook.service';
import { WebhookServer } from '@/webhooks/webhook-server';
import { BaseCommand } from './base-command';
export class Webhook extends BaseCommand {
static description = 'Starts n8n webhook process. Intercepts only production URLs.';

View file

@ -1,26 +1,27 @@
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import express from 'express';
import http from 'http';
import { ApplicationError } from 'n8n-workflow';
import { Container } from 'typedi';
import * as Db from '@/db';
import * as ResponseHelper from '@/response-helper';
import config from '@/config';
import type { ScalingService } from '@/scaling/scaling.service';
import { N8N_VERSION, inTest } from '@/constants';
import type { ICredentialsOverwrite } from '@/interfaces';
import { CredentialsOverwrites } from '@/credentials-overwrites';
import { rawBodyReader, bodyParser } from '@/middlewares';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import type { RedisServicePubSubSubscriber } from '@/services/redis/redis-service-pub-sub-subscriber';
import * as Db from '@/db';
import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error';
import { EventMessageGeneric } from '@/eventbus/event-message-classes/event-message-generic';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay';
import type { ICredentialsOverwrite } from '@/interfaces';
import { rawBodyReader, bodyParser } from '@/middlewares';
import * as ResponseHelper from '@/response-helper';
import { JobProcessor } from '@/scaling/job-processor';
import type { ScalingService } from '@/scaling/scaling.service';
import { OrchestrationHandlerWorkerService } from '@/services/orchestration/worker/orchestration.handler.worker.service';
import { OrchestrationWorkerService } from '@/services/orchestration/worker/orchestration.worker.service';
import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error';
import type { RedisServicePubSubSubscriber } from '@/services/redis/redis-service-pub-sub-subscriber';
import { BaseCommand } from './base-command';
import { JobProcessor } from '@/scaling/job-processor';
import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay';
export class Worker extends BaseCommand {
static description = '\nStarts a n8n worker';

View file

@ -1,18 +1,20 @@
import { mock } from 'jest-mock-extended';
import config from '@/config';
import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow';
import {
CLOUD_TEMP_PRODUCTION_LIMIT,
CLOUD_TEMP_REPORTABLE_THRESHOLDS,
ConcurrencyControlService,
} from '@/concurrency/concurrency-control.service';
import type { Logger } from '@/logger';
import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error';
import { ConcurrencyQueue } from '../concurrency-queue';
import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow';
import config from '@/config';
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
import type { IExecutingWorkflowData } from '@/interfaces';
import type { Telemetry } from '@/telemetry';
import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error';
import type { EventService } from '@/events/event.service';
import type { IExecutingWorkflowData } from '@/interfaces';
import type { Logger } from '@/logger';
import type { Telemetry } from '@/telemetry';
import { ConcurrencyQueue } from '../concurrency-queue';
describe('ConcurrencyControlService', () => {
const logger = mock<Logger>();

View file

@ -1,4 +1,5 @@
import { sleep } from 'n8n-workflow';
import { ConcurrencyQueue } from '../concurrency-queue';
describe('ConcurrencyQueue', () => {

View file

@ -1,14 +1,16 @@
import { Logger } from '@/logger';
import config from '@/config';
import { Service } from 'typedi';
import { ConcurrencyQueue } from './concurrency-queue';
import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error';
import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow';
import type { IExecutingWorkflowData } from '@/interfaces';
import { Telemetry } from '@/telemetry';
import { Service } from 'typedi';
import config from '@/config';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error';
import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error';
import { EventService } from '@/events/event.service';
import type { IExecutingWorkflowData } from '@/interfaces';
import { Logger } from '@/logger';
import { Telemetry } from '@/telemetry';
import { ConcurrencyQueue } from './concurrency-queue';
export const CLOUD_TEMP_PRODUCTION_LIMIT = 999;
export const CLOUD_TEMP_REPORTABLE_THRESHOLDS = [5, 10, 20, 50, 100, 200];

View file

@ -1,4 +1,5 @@
import { Service } from 'typedi';
import { TypedEmitter } from '@/typed-emitter';
type ConcurrencyEvents = {

View file

@ -1,11 +1,12 @@
import { Container } from 'typedi';
import { GlobalConfig } from '@n8n/config';
import convict from 'convict';
import dotenv from 'dotenv';
import { readFileSync } from 'fs';
import { flatten } from 'flat';
import { readFileSync } from 'fs';
import merge from 'lodash/merge';
import { GlobalConfig } from '@n8n/config';
import { ApplicationError, setGlobalState } from 'n8n-workflow';
import colors from 'picocolors';
import { Container } from 'typedi';
import { inTest, inE2ETests } from '@/constants';
@ -104,7 +105,6 @@ if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHo
config.set('userManagement.jwtRefreshTimeoutHours', 0);
}
import colors from 'picocolors';
const executionProcess = config.getEnv('executions.process');
if (executionProcess) {
console.error(

View file

@ -1,10 +1,11 @@
import path from 'path';
import { GlobalConfig } from '@n8n/config';
import convict from 'convict';
import { Container } from 'typedi';
import { InstanceSettings } from 'n8n-core';
import { LOG_LEVELS } from 'n8n-workflow';
import path from 'path';
import { Container } from 'typedi';
import { ensureStringArray } from './utils';
import { GlobalConfig } from '@n8n/config';
convict.addFormat({
name: 'comma-separated-list',

View file

@ -1,6 +1,7 @@
import type { BinaryData } from 'n8n-core';
import type { schema } from './schema';
import type { RedisOptions } from 'ioredis';
import type { BinaryData } from 'n8n-core';
import type { schema } from './schema';
// -----------------------------------
// transformers

View file

@ -1,7 +1,8 @@
import { NotStringArrayError } from '@/errors/not-string-array.error';
import type { SchemaObj } from 'convict';
import { ApplicationError } from 'n8n-workflow';
import { NotStringArrayError } from '@/errors/not-string-array.error';
export const ensureStringArray = (values: string[], { env }: SchemaObj<string>) => {
if (!env) throw new ApplicationError('Missing env', { extra: { env } });

View file

@ -1,7 +1,7 @@
import { readFileSync } from 'fs';
import { resolve, join, dirname } from 'path';
import type { n8n } from 'n8n-core';
import { jsonParse } from 'n8n-workflow';
import { resolve, join, dirname } from 'path';
const { NODE_ENV, E2E_TESTS } = process.env;
export const inProduction = NODE_ENV === 'production';

View file

@ -1,7 +1,8 @@
import type { Request } from 'express';
import { mock } from 'jest-mock-extended';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { CurlController } from '@/controllers/curl.controller';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import type { CurlService } from '@/services/curl.service';
describe('CurlController', () => {

View file

@ -1,9 +1,10 @@
import { mock } from 'jest-mock-extended';
import type { ILoadOptions, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
import { DynamicNodeParametersController } from '@/controllers/dynamic-node-parameters.controller';
import type { DynamicNodeParametersRequest } from '@/requests';
import type { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
import { mock } from 'jest-mock-extended';
import * as AdditionalData from '@/workflow-execute-additional-data';
import type { ILoadOptions, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
describe('DynamicNodeParametersController', () => {
const service = mock<DynamicNodeParametersService>();

View file

@ -1,25 +1,25 @@
import type { Response } from 'express';
import { Container } from 'typedi';
import jwt from 'jsonwebtoken';
import { mock, anyObject } from 'jest-mock-extended';
import jwt from 'jsonwebtoken';
import { Container } from 'typedi';
import type { PublicUser } from '@/interfaces';
import type { User } from '@/databases/entities/user';
import { API_KEY_PREFIX, MeController } from '@/controllers/me.controller';
import { AUTH_COOKIE_NAME } from '@/constants';
import type { AuthenticatedRequest, MeRequest } from '@/requests';
import { UserService } from '@/services/user.service';
import { ExternalHooks } from '@/external-hooks';
import { License } from '@/license';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { EventService } from '@/events/event.service';
import { badPasswords } from '@test/test-data';
import { mockInstance } from '@test/mocking';
import { API_KEY_PREFIX, MeController } from '@/controllers/me.controller';
import type { User } from '@/databases/entities/user';
import { AuthUserRepository } from '@/databases/repositories/auth-user.repository';
import { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { MfaService } from '@/mfa/mfa.service';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
import { EventService } from '@/events/event.service';
import { ExternalHooks } from '@/external-hooks';
import type { PublicUser } from '@/interfaces';
import { License } from '@/license';
import { MfaService } from '@/mfa/mfa.service';
import type { AuthenticatedRequest, MeRequest } from '@/requests';
import { UserService } from '@/services/user.service';
import { mockInstance } from '@test/mocking';
import { badPasswords } from '@test/test-data';
const browserId = 'test-browser-id';

View file

@ -1,7 +1,7 @@
import Container from 'typedi';
import type { Response } from 'express';
import { anyObject, mock } from 'jest-mock-extended';
import jwt from 'jsonwebtoken';
import Container from 'typedi';
import type { AuthService } from '@/auth/auth.service';
import config from '@/config';
@ -12,9 +12,8 @@ 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 type { UserService } from '@/services/user.service';
import { PasswordUtility } from '@/services/password.utility';
import type { UserService } from '@/services/user.service';
import { mockInstance } from '@test/mocking';
import { badPasswords } from '@test/test-data';

View file

@ -1,12 +1,13 @@
import { mock } from 'jest-mock-extended';
import config from '@/config';
import type { TranslationRequest } from '@/controllers/translation.controller';
import {
TranslationController,
CREDENTIAL_TRANSLATIONS_DIR,
} from '@/controllers/translation.controller';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import type { CredentialTypes } from '@/credential-types';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
describe('TranslationController', () => {
const configGetSpy = jest.spyOn(config, 'getEnv');

View file

@ -1,8 +1,9 @@
import { mock } from 'jest-mock-extended';
import type { NpsSurveyState } from 'n8n-workflow';
import { UserSettingsController } from '@/controllers/user-settings.controller';
import type { NpsSurveyRequest } from '@/requests';
import type { UserService } from '@/services/user.service';
import { mock } from 'jest-mock-extended';
import type { NpsSurveyState } from 'n8n-workflow';
const NOW = 1717607016208;
jest.useFakeTimers({

View file

@ -1,11 +1,13 @@
import { mock } from 'jest-mock-extended';
import { UsersController } from '../users.controller';
import type { UserRequest } from '@/requests';
import type { EventService } from '@/events/event.service';
import type { User } from '@/databases/entities/user';
import type { UserRepository } from '@/databases/repositories/user.repository';
import type { EventService } from '@/events/event.service';
import type { UserRequest } from '@/requests';
import type { ProjectService } from '@/services/project.service';
import { UsersController } from '../users.controller';
describe('UsersController', () => {
const eventService = mock<EventService>();
const userRepository = mock<UserRepository>();

View file

@ -1,8 +1,8 @@
import type { Response } from 'express';
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
import { WritableStream } from 'node:stream/web';
import { strict as assert } from 'node:assert';
import type { Response } from 'express';
import { ErrorReporterProxy } from 'n8n-workflow';
import { strict as assert } from 'node:assert';
import { WritableStream } from 'node:stream/web';
import { Post, RestController } from '@/decorators';
import { InternalServerError } from '@/errors/response-errors/internal-server.error';

View file

@ -1,6 +1,6 @@
import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators';
import { AnnotationTagService } from '@/services/annotation-tag.service';
import { AnnotationTagsRequest } from '@/requests';
import { AnnotationTagService } from '@/services/annotation-tag.service';
@RestController('/annotation-tags')
export class AnnotationTagsController {

View file

@ -1,29 +1,29 @@
import validator from 'validator';
import { Response } from 'express';
import { ApplicationError } from 'n8n-workflow';
import validator from 'validator';
import { handleEmailLogin, handleLdapLogin } from '@/auth';
import { AuthService } from '@/auth/auth.service';
import { Get, Post, RestController } from '@/decorators';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import type { User } from '@/databases/entities/user';
import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests';
import { UserRepository } from '@/databases/repositories/user.repository';
import { Get, Post, 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';
import { EventService } from '@/events/event.service';
import type { PublicUser } from '@/interfaces';
import { handleEmailLogin, handleLdapLogin } from '@/auth';
import { License } from '@/license';
import { Logger } from '@/logger';
import { MfaService } from '@/mfa/mfa.service';
import { PostHogClient } from '@/posthog';
import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests';
import { UserService } from '@/services/user.service';
import {
getCurrentAuthenticationMethod,
isLdapCurrentAuthenticationMethod,
isSamlCurrentAuthenticationMethod,
} from '@/sso/sso-helpers';
import { License } from '@/license';
import { UserService } from '@/services/user.service';
import { MfaService } from '@/mfa/mfa.service';
import { Logger } from '@/logger';
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';
import { ApplicationError } from 'n8n-workflow';
import { UserRepository } from '@/databases/repositories/user.repository';
import { EventService } from '@/events/event.service';
@RestController()
export class AuthController {

View file

@ -1,5 +1,6 @@
import express from 'express';
import { BinaryDataService, FileNotFoundError, isValidNonDefaultMode } from 'n8n-core';
import { Get, RestController } from '@/decorators';
import { BinaryDataRequest } from '@/requests';

View file

@ -3,15 +3,15 @@ import {
STARTER_TEMPLATE_NAME,
UNKNOWN_FAILURE_REASON,
} from '@/constants';
import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators';
import { NodeRequest } from '@/requests';
import type { InstalledPackages } from '@/databases/entities/installed-packages';
import type { CommunityPackages } from '@/interfaces';
import { Push } from '@/push';
import { CommunityPackagesService } from '@/services/community-packages.service';
import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators';
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 type { CommunityPackages } from '@/interfaces';
import { Push } from '@/push';
import { NodeRequest } from '@/requests';
import { CommunityPackagesService } from '@/services/community-packages.service';
const {
PACKAGE_NOT_INSTALLED,

View file

@ -1,4 +1,5 @@
import express from 'express';
import { Get, RestController } from '@/decorators';
import { AuthenticatedRequest } from '@/requests';
import { CtaService } from '@/services/cta.service';

View file

@ -1,4 +1,5 @@
import { Request } from 'express';
import { Post, RestController } from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { CurlService, flattenObject } from '@/services/curl.service';

View file

@ -1,7 +1,7 @@
import { Get, RestController } from '@/decorators';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import { OrchestrationService } from '@/services/orchestration.service';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { Get, RestController } from '@/decorators';
import { OrchestrationService } from '@/services/orchestration.service';
@RestController('/debug')
export class DebugController {

View file

@ -1,10 +1,10 @@
import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow';
import { Post, RestController } from '@/decorators';
import { getBase } from '@/workflow-execute-additional-data';
import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
import { DynamicNodeParametersRequest } from '@/requests';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { DynamicNodeParametersRequest } from '@/requests';
import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
import { getBase } from '@/workflow-execute-additional-data';
@RestController('/dynamic-node-parameters')
export class DynamicNodeParametersController {

View file

@ -1,22 +1,23 @@
import { Request } from 'express';
import Container from 'typedi';
import { v4 as uuid } from 'uuid';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import config from '@/config';
import { LICENSE_FEATURES, LICENSE_QUOTAS, UNLIMITED_LICENSE_QUOTA, inE2ETests } from '@/constants';
import { AuthUserRepository } from '@/databases/repositories/auth-user.repository';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import { License } from '@/license';
import { LICENSE_FEATURES, LICENSE_QUOTAS, UNLIMITED_LICENSE_QUOTA, inE2ETests } from '@/constants';
import { Patch, Post, RestController } from '@/decorators';
import type { UserSetupPayload } from '@/requests';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
import type { BooleanLicenseFeature, IPushDataType, NumericLicenseFeature } from '@/interfaces';
import { License } from '@/license';
import { Logger } from '@/logger';
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';
import Container from 'typedi';
import { Logger } from '@/logger';
import { AuthUserRepository } from '@/databases/repositories/auth-user.repository';
if (!inE2ETests) {
Container.get(Logger).error('E2E endpoints only allowed during E2E tests');

View file

@ -3,21 +3,21 @@ import validator from 'validator';
import { AuthService } from '@/auth/auth.service';
import config from '@/config';
import { Post, GlobalScope, RestController } from '@/decorators';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { UserRequest } from '@/requests';
import { License } from '@/license';
import { UserService } from '@/services/user.service';
import { Logger } from '@/logger';
import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers';
import { PasswordUtility } from '@/services/password.utility';
import { PostHogClient } from '@/posthog';
import type { User } from '@/databases/entities/user';
import { UserRepository } from '@/databases/repositories/user.repository';
import { Post, GlobalScope, RestController } from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
import { ExternalHooks } from '@/external-hooks';
import { EventService } from '@/events/event.service';
import { ExternalHooks } from '@/external-hooks';
import { License } from '@/license';
import { Logger } from '@/logger';
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';
@RestController('/invitations')
export class InvitationController {

View file

@ -1,30 +1,31 @@
import validator from 'validator';
import { plainToInstance } from 'class-transformer';
import { type RequestHandler, Response } from 'express';
import { randomBytes } from 'crypto';
import { type RequestHandler, Response } from 'express';
import validator from 'validator';
import { AuthService } from '@/auth/auth.service';
import { Delete, Get, Patch, Post, RestController } from '@/decorators';
import { PasswordUtility } from '@/services/password.utility';
import { validateEntity } from '@/generic-helpers';
import type { User } from '@/databases/entities/user';
import { UserRepository } from '@/databases/repositories/user.repository';
import { Delete, Get, Patch, Post, RestController } from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
import { EventService } from '@/events/event.service';
import { ExternalHooks } from '@/external-hooks';
import { validateEntity } from '@/generic-helpers';
import type { PublicUser } from '@/interfaces';
import { Logger } from '@/logger';
import { MfaService } from '@/mfa/mfa.service';
import { isApiEnabled } from '@/public-api';
import {
AuthenticatedRequest,
MeRequest,
UserSettingsUpdatePayload,
UserUpdatePayload,
} from '@/requests';
import type { PublicUser } from '@/interfaces';
import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers';
import { PasswordUtility } from '@/services/password.utility';
import { UserService } from '@/services/user.service';
import { Logger } from '@/logger';
import { ExternalHooks } from '@/external-hooks';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { UserRepository } from '@/databases/repositories/user.repository';
import { isApiEnabled } from '@/public-api';
import { EventService } from '@/events/event.service';
import { MfaService } from '@/mfa/mfa.service';
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers';
import { PersonalizationSurveyAnswersV4 } from './survey-answers.dto';
export const API_KEY_PREFIX = 'n8n_api_';

View file

@ -1,7 +1,7 @@
import { Get, Post, RestController } from '@/decorators';
import { AuthenticatedRequest, MFA } from '@/requests';
import { MfaService } from '@/mfa/mfa.service';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { MfaService } from '@/mfa/mfa.service';
import { AuthenticatedRequest, MFA } from '@/requests';
@RestController('/mfa')
export class MFAController {

View file

@ -1,9 +1,10 @@
import { Request } from 'express';
import { readFile } from 'fs/promises';
import get from 'lodash/get';
import { Request } from 'express';
import type { INodeTypeDescription, INodeTypeNameVersion } from 'n8n-workflow';
import { Post, RestController } from '@/decorators';
import config from '@/config';
import { Post, RestController } from '@/decorators';
import { NodeTypes } from '@/node-types';
@RestController('/node-types')

View file

@ -1,24 +1,23 @@
import Csrf from 'csrf';
import type { Response } from 'express';
import { mock } from 'jest-mock-extended';
import { Cipher } from 'n8n-core';
import nock from 'nock';
import Container from 'typedi';
import type { Response } from 'express';
import Csrf from 'csrf';
import { Cipher } from 'n8n-core';
import { mock } from 'jest-mock-extended';
import { OAuth1CredentialController } from '@/controllers/oauth/oauth1-credential.controller';
import { CredentialsHelper } from '@/credentials-helper';
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
import type { User } from '@/databases/entities/user';
import type { OAuthRequest } from '@/requests';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { ExternalHooks } from '@/external-hooks';
import { Logger } from '@/logger';
import { VariablesService } from '@/environments/variables/variables.service.ee';
import { SecretsHelper } from '@/secrets-helpers';
import { CredentialsHelper } from '@/credentials-helper';
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 '@/logger';
import type { OAuthRequest } from '@/requests';
import { SecretsHelper } from '@/secrets-helpers';
import { mockInstance } from '@test/mocking';
describe('OAuth1CredentialController', () => {

View file

@ -1,24 +1,23 @@
import nock from 'nock';
import Container from 'typedi';
import Csrf from 'csrf';
import { type Response } from 'express';
import { Cipher } from 'n8n-core';
import { mock } from 'jest-mock-extended';
import { Cipher } from 'n8n-core';
import nock from 'nock';
import Container from 'typedi';
import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller';
import { CredentialsHelper } from '@/credentials-helper';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import type { User } from '@/databases/entities/user';
import type { OAuthRequest } from '@/requests';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { ExternalHooks } from '@/external-hooks';
import { Logger } from '@/logger';
import { VariablesService } from '@/environments/variables/variables.service.ee';
import { SecretsHelper } from '@/secrets-helpers';
import { CredentialsHelper } from '@/credentials-helper';
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 '@/logger';
import type { OAuthRequest } from '@/requests';
import { SecretsHelper } from '@/secrets-helpers';
import { mockInstance } from '@test/mocking';
describe('OAuth2CredentialController', () => {

View file

@ -1,24 +1,24 @@
import { Service } from 'typedi';
import { GlobalConfig } from '@n8n/config';
import Csrf from 'csrf';
import type { Response } from 'express';
import { Credentials } from 'n8n-core';
import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
import { jsonParse, ApplicationError } from 'n8n-workflow';
import { Service } from 'typedi';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { CredentialsHelper } from '@/credentials-helper';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import type { ICredentialsDb } from '@/interfaces';
import type { OAuthRequest } from '@/requests';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { CredentialsHelper } from '@/credentials-helper';
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
import { Logger } from '@/logger';
import { ExternalHooks } from '@/external-hooks';
import { UrlService } from '@/services/url.service';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { GlobalConfig } from '@n8n/config';
import { ExternalHooks } from '@/external-hooks';
import type { ICredentialsDb } from '@/interfaces';
import { Logger } from '@/logger';
import type { OAuthRequest } from '@/requests';
import { UrlService } from '@/services/url.service';
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
export interface CsrfStateParam {
cid: string;

View file

@ -1,14 +1,16 @@
import { Response } from 'express';
import type { AxiosRequestConfig } from 'axios';
import axios from 'axios';
import { createHmac } from 'crypto';
import { Response } from 'express';
import type { RequestOptions } from 'oauth-1.0a';
import clientOAuth1 from 'oauth-1.0a';
import { createHmac } from 'crypto';
import { Get, RestController } from '@/decorators';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { OAuthRequest } from '@/requests';
import { sendErrorResponse } from '@/response-helper';
import { AbstractOAuthController, type CsrfStateParam } from './abstract-oauth.controller';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
interface OAuth1CredentialData {
signatureMethod: 'HMAC-SHA256' | 'HMAC-SHA512' | 'HMAC-SHA1';

View file

@ -1,14 +1,16 @@
import type { ClientOAuth2Options, OAuth2CredentialData } from '@n8n/client-oauth2';
import { ClientOAuth2 } from '@n8n/client-oauth2';
import { Response } from 'express';
import pkceChallenge from 'pkce-challenge';
import * as qs from 'querystring';
import omit from 'lodash/omit';
import set from 'lodash/set';
import split from 'lodash/split';
import { Get, RestController } from '@/decorators';
import { jsonStringify } from 'n8n-workflow';
import pkceChallenge from 'pkce-challenge';
import * as qs from 'querystring';
import { Get, RestController } from '@/decorators';
import { OAuthRequest } from '@/requests';
import { AbstractOAuthController, type CsrfStateParam } from './abstract-oauth.controller';
import { GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE as GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE } from '../../constants';

View file

@ -1,7 +1,7 @@
import { Post, RestController, GlobalScope } from '@/decorators';
import { License } from '@/license';
import { OrchestrationRequest } from '@/requests';
import { OrchestrationService } from '@/services/orchestration.service';
import { License } from '@/license';
@RestController('/orchestration')
export class OrchestrationController {

View file

@ -1,19 +1,19 @@
import validator from 'validator';
import { Response } from 'express';
import validator from 'validator';
import { AuthService } from '@/auth/auth.service';
import config from '@/config';
import { validateEntity } from '@/generic-helpers';
import { GlobalScope, Post, RestController } from '@/decorators';
import { PasswordUtility } from '@/services/password.utility';
import { OwnerRequest } from '@/requests';
import { SettingsRepository } from '@/databases/repositories/settings.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { PostHogClient } from '@/posthog';
import { UserService } from '@/services/user.service';
import { Logger } from '@/logger';
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 '@/logger';
import { PostHogClient } from '@/posthog';
import { OwnerRequest } from '@/requests';
import { PasswordUtility } from '@/services/password.utility';
import { UserService } from '@/services/user.service';
@RestController('/owner')
export class OwnerController {

View file

@ -2,24 +2,24 @@ import { Response } from 'express';
import validator from 'validator';
import { AuthService } from '@/auth/auth.service';
import { Get, Post, RestController } from '@/decorators';
import { PasswordUtility } from '@/services/password.utility';
import { UserManagementMailer } from '@/user-management/email';
import { PasswordResetRequest } from '@/requests';
import { isSamlCurrentAuthenticationMethod } from '@/sso/sso-helpers';
import { UserService } from '@/services/user.service';
import { License } from '@/license';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { MfaService } from '@/mfa/mfa.service';
import { Logger } from '@/logger';
import { ExternalHooks } from '@/external-hooks';
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
import { UserRepository } from '@/databases/repositories/user.repository';
import { Get, Post, 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';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error';
import { UserRepository } from '@/databases/repositories/user.repository';
import { EventService } from '@/events/event.service';
import { ExternalHooks } from '@/external-hooks';
import { License } from '@/license';
import { Logger } from '@/logger';
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 { UserManagementMailer } from '@/user-management/email';
@RestController()
export class PasswordResetController {

View file

@ -1,4 +1,10 @@
import { combineScopes } from '@n8n/permissions';
import type { Scope } from '@n8n/permissions';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In, Not } from '@n8n/typeorm';
import type { Project } from '@/databases/entities/project';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import {
Get,
Post,
@ -9,21 +15,16 @@ import {
ProjectScope,
Delete,
} from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { EventService } from '@/events/event.service';
import { ProjectRequest } from '@/requests';
import {
ProjectService,
TeamProjectOverQuotaError,
UnlicensedProjectRoleError,
} from '@/services/project.service';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { combineScopes } from '@n8n/permissions';
import type { Scope } from '@n8n/permissions';
import { RoleService } from '@/services/role.service';
import { ProjectRepository } from '@/databases/repositories/project.repository';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In, Not } from '@n8n/typeorm';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { EventService } from '@/events/event.service';
@RestController('/projects')
export class ProjectController {

View file

@ -1,8 +1,9 @@
import { NoXss } from '@/validators/no-xss.validator';
import { Expose } from 'class-transformer';
import { IsString, IsArray, IsOptional, IsEmail, IsEnum } from 'class-validator';
import type { IPersonalizationSurveyAnswersV4 } from 'n8n-workflow';
import { NoXss } from '@/validators/no-xss.validator';
export class PersonalizationSurveyAnswersV4 implements IPersonalizationSurveyAnswersV4 {
@NoXss()
@Expose()

View file

@ -1,9 +1,10 @@
import { Request, Response, NextFunction } from 'express';
import config from '@/config';
import { Delete, Get, Middleware, Patch, Post, RestController, GlobalScope } from '@/decorators';
import { TagService } from '@/services/tag.service';
import { TagsRequest } from '@/requests';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { TagsRequest } from '@/requests';
import { TagService } from '@/services/tag.service';
@RestController('/tags')
export class TagsController {

View file

@ -1,12 +1,13 @@
import type { Request } from 'express';
import { join } from 'path';
import { access } from 'fs/promises';
import { Get, RestController } from '@/decorators';
import { join } from 'path';
import config from '@/config';
import { NODES_BASE_DIR } from '@/constants';
import { CredentialTypes } from '@/credential-types';
import { Get, RestController } from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
import { CredentialTypes } from '@/credential-types';
export const CREDENTIAL_TRANSLATIONS_DIR = 'n8n-nodes-base/dist/credentials/translations';
export const NODE_HEADERS_PATH = join(NODES_BASE_DIR, 'dist/nodes/headers');

View file

@ -1,8 +1,9 @@
import type { NpsSurveyState } from 'n8n-workflow';
import { Patch, RestController } from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { NpsSurveyRequest } from '@/requests';
import { UserService } from '@/services/user.service';
import type { NpsSurveyState } from 'n8n-workflow';
function getNpsSurveyState(state: unknown): NpsSurveyState | undefined {
if (typeof state !== 'object' || state === null) {

View file

@ -1,33 +1,33 @@
import { plainToInstance } from 'class-transformer';
import { AuthService } from '@/auth/auth.service';
import { CredentialsService } from '@/credentials/credentials.service';
import { AuthIdentity } from '@/databases/entities/auth-identity';
import { Project } from '@/databases/entities/project';
import { User } from '@/databases/entities/user';
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 } 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';
import { EventService } from '@/events/event.service';
import { ExternalHooks } from '@/external-hooks';
import { validateEntity } from '@/generic-helpers';
import type { PublicUser } from '@/interfaces';
import { Logger } from '@/logger';
import { listQueryMiddleware } from '@/middlewares';
import {
ListQuery,
UserRequest,
UserRoleChangePayload,
UserSettingsUpdatePayload,
} from '@/requests';
import type { PublicUser } from '@/interfaces';
import { AuthIdentity } from '@/databases/entities/auth-identity';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import { UserService } from '@/services/user.service';
import { listQueryMiddleware } from '@/middlewares';
import { Logger } from '@/logger';
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { ExternalHooks } from '@/external-hooks';
import { validateEntity } from '@/generic-helpers';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { Project } from '@/databases/entities/project';
import { WorkflowService } from '@/workflows/workflow.service';
import { CredentialsService } from '@/credentials/credentials.service';
import { ProjectService } from '@/services/project.service';
import { EventService } from '@/events/event.service';
import { UserService } from '@/services/user.service';
import { WorkflowService } from '@/workflows/workflow.service';
@RestController('/users')
export class UsersController {

View file

@ -1,12 +1,14 @@
import { Response, NextFunction } from 'express';
import { Get, Middleware, RestController } from '@/decorators';
import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics';
import { StatisticsNames } from '@/databases/entities/workflow-statistics';
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository';
import { Get, Middleware, RestController } from '@/decorators';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import type { IWorkflowStatisticsDataLoaded } from '@/interfaces';
import { Logger } from '@/logger';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { StatisticsRequest } from './workflow-statistics.types';
interface WorkflowStatisticsData<T> {

View file

@ -1,9 +1,10 @@
import { existsSync } from 'fs';
import { mkdir, utimes, open, rm } from 'fs/promises';
import { join, dirname } from 'path';
import { Container } from 'typedi';
import { InstanceSettings } from 'n8n-core';
import { sleep } from 'n8n-workflow';
import { join, dirname } from 'path';
import { Container } from 'typedi';
import { inProduction } from '@/constants';
import { Logger } from '@/logger';

View file

@ -1,4 +1,3 @@
import { Service } from 'typedi';
import { loadClassInIsolation } from 'n8n-core';
import {
ApplicationError,
@ -6,6 +5,8 @@ import {
type ICredentialTypes,
type LoadedClass,
} from 'n8n-workflow';
import { Service } from 'typedi';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';

View file

@ -2,9 +2,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Service } from 'typedi';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In } from '@n8n/typeorm';
import { Credentials, NodeExecuteFunctions } from 'n8n-core';
import type {
ICredentialDataDecryptedObject,
ICredentialsExpressionResolveValues,
@ -26,19 +26,17 @@ import type {
IDataObject,
} from 'n8n-workflow';
import { ICredentialsHelper, NodeHelpers, Workflow, ApplicationError } from 'n8n-workflow';
import { Service } from 'typedi';
import type { ICredentialsDb } from '@/interfaces';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { CredentialTypes } from '@/credential-types';
import { CredentialsOverwrites } from '@/credentials-overwrites';
import { RESPONSE_ERROR_MESSAGES } from './constants';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import type { ICredentialsDb } from '@/interfaces';
import { RESPONSE_ERROR_MESSAGES } from './constants';
import { CredentialNotFoundError } from './errors/credential-not-found.error';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In } from '@n8n/typeorm';
import { CacheService } from './services/cache/cache.service';
const mockNode = {

View file

@ -1,9 +1,10 @@
import { Service } from 'typedi';
import { GlobalConfig } from '@n8n/config';
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import { deepCopy, jsonParse } from 'n8n-workflow';
import type { ICredentialsOverwrite } from '@/interfaces';
import { Service } from 'typedi';
import { CredentialTypes } from '@/credential-types';
import type { ICredentialsOverwrite } from '@/interfaces';
import { Logger } from '@/logger';
@Service()

View file

@ -1,9 +1,10 @@
import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow';
import { mock } from 'jest-mock-extended';
import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow';
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import type { CredentialTypes } from '@/credential-types';
import { CredentialsService } from '@/credentials/credentials.service';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
describe('CredentialsService', () => {
const credType = mock<ICredentialType>({

View file

@ -1,16 +1,13 @@
import { deepCopy } from 'n8n-workflow';
import { GlobalConfig } from '@n8n/config';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In } from '@n8n/typeorm';
import { deepCopy } from 'n8n-workflow';
import { z } from 'zod';
import { CredentialsService } from './credentials.service';
import { CredentialRequest } from '@/requests';
import { Logger } from '@/logger';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
import { NamingService } from '@/services/naming.service';
import { License } from '@/license';
import { EnterpriseCredentialsService } from './credentials.service.ee';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import * as Db from '@/db';
import {
Delete,
Get,
@ -22,15 +19,19 @@ import {
ProjectScope,
} from '@/decorators';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { UserManagementMailer } from '@/user-management/email';
import * as Db from '@/db';
import * as utils from '@/utils';
import { listQueryMiddleware } from '@/middlewares';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
import { z } from 'zod';
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 '@/logger';
import { listQueryMiddleware } from '@/middlewares';
import { CredentialRequest } from '@/requests';
import { NamingService } from '@/services/naming.service';
import { UserManagementMailer } from '@/user-management/email';
import * as utils from '@/utils';
import { CredentialsService } from './credentials.service';
import { EnterpriseCredentialsService } from './credentials.service.ee';
@RestController('/credentials')
export class CredentialsController {

View file

@ -1,19 +1,21 @@
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import { In, type EntityManager } from '@n8n/typeorm';
import type { User } from '@/databases/entities/user';
import { CredentialsService } from './credentials.service';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { Service } from 'typedi';
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { OwnershipService } from '@/services/ownership.service';
import { Service } from 'typedi';
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { Project } from '@/databases/entities/project';
import { ProjectService } from '@/services/project.service';
import { TransferCredentialError } from '@/errors/response-errors/transfer-credential.error';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import type { User } from '@/databases/entities/user';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
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 { RoleService } from '@/services/role.service';
import { CredentialsService } from './credentials.service';
@Service()
export class EnterpriseCredentialsService {
constructor(

View file

@ -1,3 +1,11 @@
import type { Scope } from '@n8n/permissions';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import {
In,
type EntityManager,
type FindOptionsRelations,
type FindOptionsWhere,
} from '@n8n/typeorm';
import { Credentials } from 'n8n-core';
import type {
ICredentialDataDecryptedObject,
@ -6,39 +14,32 @@ import type {
INodeProperties,
} from 'n8n-workflow';
import { ApplicationError, CREDENTIAL_EMPTY_VALUE, deepCopy, NodeHelpers } from 'n8n-workflow';
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
import {
In,
type EntityManager,
type FindOptionsRelations,
type FindOptionsWhere,
} from '@n8n/typeorm';
import type { Scope } from '@n8n/permissions';
import * as Db from '@/db';
import type { ICredentialsDb } from '@/interfaces';
import { createCredentialsFromCredentialsEntity } from '@/credentials-helper';
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import { validateEntity } from '@/generic-helpers';
import { ExternalHooks } from '@/external-hooks';
import type { User } from '@/databases/entities/user';
import type { CredentialRequest, ListQuery } from '@/requests';
import { CredentialTypes } from '@/credential-types';
import { OwnershipService } from '@/services/ownership.service';
import { Logger } from '@/logger';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { Service } from 'typedi';
import { CredentialsTester } from '@/services/credentials-tester.service';
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
import { CredentialTypes } from '@/credential-types';
import { createCredentialsFromCredentialsEntity } from '@/credentials-helper';
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
import type { ProjectRelation } from '@/databases/entities/project-relation';
import { SharedCredentials } from '@/databases/entities/shared-credentials';
import type { User } from '@/databases/entities/user';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { ProjectService } from '@/services/project.service';
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
import { UserRepository } from '@/databases/repositories/user.repository';
import * as Db from '@/db';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import type { ProjectRelation } from '@/databases/entities/project-relation';
import { RoleService } from '@/services/role.service';
import { UserRepository } from '@/databases/repositories/user.repository';
import { ExternalHooks } from '@/external-hooks';
import { validateEntity } from '@/generic-helpers';
import type { ICredentialsDb } from '@/interfaces';
import { Logger } from '@/logger';
import { userHasScope } from '@/permissions/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 { RoleService } from '@/services/role.service';
export type CredentialsGetSharedOptions =
| { allowGlobalScope: true; globalScope: Scope }

View file

@ -1,20 +1,20 @@
import path from 'path';
import { Container } from 'typedi';
import type { TlsOptions } from 'tls';
import { GlobalConfig } from '@n8n/config';
import type { DataSourceOptions, LoggerOptions } from '@n8n/typeorm';
import type { MysqlConnectionOptions } from '@n8n/typeorm/driver/mysql/MysqlConnectionOptions';
import type { PostgresConnectionOptions } from '@n8n/typeorm/driver/postgres/PostgresConnectionOptions';
import type { SqliteConnectionOptions } from '@n8n/typeorm/driver/sqlite/SqliteConnectionOptions';
import type { SqlitePooledConnectionOptions } from '@n8n/typeorm/driver/sqlite-pooled/SqlitePooledConnectionOptions';
import type { PostgresConnectionOptions } from '@n8n/typeorm/driver/postgres/PostgresConnectionOptions';
import type { MysqlConnectionOptions } from '@n8n/typeorm/driver/mysql/MysqlConnectionOptions';
import { InstanceSettings } from 'n8n-core';
import { ApplicationError } from 'n8n-workflow';
import { GlobalConfig } from '@n8n/config';
import path from 'path';
import type { TlsOptions } from 'tls';
import { Container } from 'typedi';
import { entities } from './entities';
import { subscribers } from './subscribers';
import { mysqlMigrations } from './migrations/mysqldb';
import { postgresMigrations } from './migrations/postgresdb';
import { sqliteMigrations } from './migrations/sqlite';
import { subscribers } from './subscribers';
const getCommonOptions = () => {
const { tablePrefix: entityPrefix, logging: loggingConfig } =

View file

@ -1,5 +1,7 @@
import type { QueryRunner } from '@n8n/typeorm';
import { Column } from './column';
import { CreateIndex, DropIndex } from './indices';
import {
AddColumns,
AddForeignKey,
@ -10,7 +12,6 @@ import {
DropNotNull,
DropTable,
} from './table';
import { CreateIndex, DropIndex } from './indices';
export const createSchemaBuilder = (tablePrefix: string, queryRunner: QueryRunner) => ({
column: (name: string) => new Column(name),

View file

@ -1,8 +1,9 @@
import type { TableForeignKeyOptions, TableIndexOptions, QueryRunner } from '@n8n/typeorm';
import { Table, TableColumn, TableForeignKey } from '@n8n/typeorm';
import LazyPromise from 'p-lazy';
import { Column } from './column';
import { ApplicationError } from 'n8n-workflow';
import LazyPromise from 'p-lazy';
import { Column } from './column';
abstract class TableOperation<R = void> extends LazyPromise<R> {
abstract execute(queryRunner: QueryRunner): Promise<R>;

View file

@ -1,4 +1,3 @@
import { Container } from 'typedi';
import { GlobalConfig } from '@n8n/config';
import type { ColumnOptions } from '@n8n/typeorm';
import {
@ -9,6 +8,8 @@ import {
UpdateDateColumn,
} from '@n8n/typeorm';
import type { Class } from 'n8n-core';
import { Container } from 'typedi';
import { generateNanoId } from '../utils/generators';
export const { type: dbType } = Container.get(GlobalConfig).database;

View file

@ -1,8 +1,10 @@
import { Column, Entity, Index, ManyToMany, OneToMany } from '@n8n/typeorm';
import { IsString, Length } from 'class-validator';
import { WithTimestampsAndStringId } from './abstract-entity';
import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation';
import type { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping';
import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation';
import { WithTimestampsAndStringId } from './abstract-entity';
@Entity()
export class AnnotationTagEntity extends WithTimestampsAndStringId {

View file

@ -1,6 +1,7 @@
import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
import type { ExecutionAnnotation } from './execution-annotation';
import type { AnnotationTagEntity } from './annotation-tag-entity';
import type { ExecutionAnnotation } from './execution-annotation';
/**
* This entity represents the junction table between the execution annotations and the tags

Some files were not shown because too many files have changed in this diff Show more