mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Move integration test utils for insights (#16693)
This commit is contained in:
@@ -48,22 +48,19 @@ export class ModuleRegistry {
|
|||||||
* setup.
|
* setup.
|
||||||
*/
|
*/
|
||||||
async loadModules(modules?: ModuleName[]) {
|
async loadModules(modules?: ModuleName[]) {
|
||||||
const moduleDir = process.env.NODE_ENV === 'test' ? 'src' : 'dist';
|
|
||||||
let modulesDir: string;
|
let modulesDir: string;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'test') {
|
try {
|
||||||
modulesDir = path.resolve(__dirname, `../../../../cli/${moduleDir}/modules`);
|
// docker
|
||||||
} else {
|
const n8nPackagePath = require.resolve('n8n/package.json');
|
||||||
try {
|
const n8nRoot = path.dirname(n8nPackagePath);
|
||||||
// For Docker
|
modulesDir = path.join(n8nRoot, 'src', 'modules');
|
||||||
const n8nPackagePath = require.resolve('n8n/package.json');
|
} catch {
|
||||||
const n8nRoot = path.dirname(n8nPackagePath);
|
// local dev
|
||||||
modulesDir = path.join(n8nRoot, moduleDir, 'modules');
|
const dir = process.env.NODE_ENV === 'test' ? 'src' : 'dist';
|
||||||
} catch {
|
modulesDir = path.resolve(__dirname, `../../../../cli/${dir}/modules`);
|
||||||
// Fallback to relative path for development
|
|
||||||
modulesDir = path.resolve(__dirname, `../../../../cli/${moduleDir}/modules`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const moduleName of modules ?? this.eligibleModules) {
|
for (const moduleName of modules ?? this.eligibleModules) {
|
||||||
try {
|
try {
|
||||||
await import(`${modulesDir}/${moduleName}/${moduleName}.module`);
|
await import(`${modulesDir}/${moduleName}/${moduleName}.module`);
|
||||||
|
|||||||
@@ -22,8 +22,16 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@n8n/backend-common": "workspace:^",
|
"@n8n/backend-common": "workspace:^",
|
||||||
|
"@n8n/config": "workspace:^",
|
||||||
|
"@n8n/constants": "workspace:^",
|
||||||
|
"@n8n/db": "workspace:^",
|
||||||
|
"@n8n/di": "workspace:^",
|
||||||
|
"@n8n/permissions": "workspace:^",
|
||||||
|
"@n8n/typeorm": "catalog:",
|
||||||
"jest-mock-extended": "^3.0.4",
|
"jest-mock-extended": "^3.0.4",
|
||||||
"reflect-metadata": "catalog:"
|
"n8n-workflow": "workspace:^",
|
||||||
|
"reflect-metadata": "catalog:",
|
||||||
|
"uuid": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@n8n/typescript-config": "workspace:*"
|
"@n8n/typescript-config": "workspace:*"
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
import type { Project } from '@n8n/db';
|
import type { Project, User, ProjectRelation } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import { ProjectRelationRepository, ProjectRepository } from '@n8n/db';
|
||||||
import type { ProjectRelation } from '@n8n/db';
|
|
||||||
import { ProjectRelationRepository } from '@n8n/db';
|
|
||||||
import { ProjectRepository } from '@n8n/db';
|
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type { ProjectRole } from '@n8n/permissions';
|
import type { ProjectRole } from '@n8n/permissions';
|
||||||
|
|
||||||
import { randomName } from '../random';
|
import { randomName } from '../random';
|
||||||
|
|
||||||
|
export const linkUserToProject = async (user: User, project: Project, role: ProjectRole) => {
|
||||||
|
const projectRelationRepository = Container.get(ProjectRelationRepository);
|
||||||
|
await projectRelationRepository.save(
|
||||||
|
projectRelationRepository.create({
|
||||||
|
projectId: project.id,
|
||||||
|
userId: user.id,
|
||||||
|
role,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const createTeamProject = async (name?: string, adminUser?: User) => {
|
export const createTeamProject = async (name?: string, adminUser?: User) => {
|
||||||
const projectRepository = Container.get(ProjectRepository);
|
const projectRepository = Container.get(ProjectRepository);
|
||||||
const project = await projectRepository.save(
|
const project = await projectRepository.save(
|
||||||
@@ -24,17 +32,6 @@ export const createTeamProject = async (name?: string, adminUser?: User) => {
|
|||||||
return project;
|
return project;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const linkUserToProject = async (user: User, project: Project, role: ProjectRole) => {
|
|
||||||
const projectRelationRepository = Container.get(ProjectRelationRepository);
|
|
||||||
await projectRelationRepository.save(
|
|
||||||
projectRelationRepository.create({
|
|
||||||
projectId: project.id,
|
|
||||||
userId: user.id,
|
|
||||||
role,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function getProjectByNameOrFail(name: string) {
|
export async function getProjectByNameOrFail(name: string) {
|
||||||
return await Container.get(ProjectRepository).findOneOrFail({ where: { name } });
|
return await Container.get(ProjectRepository).findOneOrFail({ where: { name } });
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import type { SharedWorkflow } from '@n8n/db';
|
import type { SharedWorkflow, IWorkflowDb } from '@n8n/db';
|
||||||
import type { IWorkflowDb } from '@n8n/db';
|
import {
|
||||||
import { Project } from '@n8n/db';
|
Project,
|
||||||
import { User } from '@n8n/db';
|
User,
|
||||||
import { ProjectRepository } from '@n8n/db';
|
ProjectRepository,
|
||||||
import { SharedWorkflowRepository } from '@n8n/db';
|
SharedWorkflowRepository,
|
||||||
import { WorkflowRepository } from '@n8n/db';
|
WorkflowRepository,
|
||||||
|
} from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type { WorkflowSharingRole } from '@n8n/permissions';
|
import type { WorkflowSharingRole } from '@n8n/permissions';
|
||||||
import type { DeepPartial } from '@n8n/typeorm';
|
import type { DeepPartial } from '@n8n/typeorm';
|
||||||
@@ -12,17 +13,6 @@ import type { IWorkflowBase } from 'n8n-workflow';
|
|||||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
export async function createManyWorkflows(
|
|
||||||
amount: number,
|
|
||||||
attributes: Partial<IWorkflowDb> = {},
|
|
||||||
user?: User,
|
|
||||||
) {
|
|
||||||
const workflowRequests = [...Array(amount)].map(
|
|
||||||
async (_) => await createWorkflow(attributes, user),
|
|
||||||
);
|
|
||||||
return await Promise.all(workflowRequests);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function newWorkflow(attributes: Partial<IWorkflowDb> = {}): IWorkflowDb {
|
export function newWorkflow(attributes: Partial<IWorkflowDb> = {}): IWorkflowDb {
|
||||||
const { active, isArchived, name, nodes, connections, versionId, settings } = attributes;
|
const { active, isArchived, name, nodes, connections, versionId, settings } = attributes;
|
||||||
|
|
||||||
@@ -86,6 +76,18 @@ export async function createWorkflow(
|
|||||||
return workflow;
|
return workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function createManyWorkflows(
|
||||||
|
amount: number,
|
||||||
|
attributes: Partial<IWorkflowDb> = {},
|
||||||
|
user?: User,
|
||||||
|
) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
|
const workflowRequests = [...Array(amount)].map(
|
||||||
|
async (_) => await createWorkflow(attributes, user),
|
||||||
|
);
|
||||||
|
return await Promise.all(workflowRequests);
|
||||||
|
}
|
||||||
|
|
||||||
export async function shareWorkflowWithUsers(workflow: IWorkflowBase, users: User[]) {
|
export async function shareWorkflowWithUsers(workflow: IWorkflowBase, users: User[]) {
|
||||||
const sharedWorkflows: Array<DeepPartial<SharedWorkflow>> = await Promise.all(
|
const sharedWorkflows: Array<DeepPartial<SharedWorkflow>> = await Promise.all(
|
||||||
users.map(async (user) => {
|
users.map(async (user) => {
|
||||||
@@ -3,3 +3,10 @@ import { mock } from 'jest-mock-extended';
|
|||||||
|
|
||||||
export const mockLogger = (): Logger =>
|
export const mockLogger = (): Logger =>
|
||||||
mock<Logger>({ scoped: jest.fn().mockReturnValue(mock<Logger>()) });
|
mock<Logger>({ scoped: jest.fn().mockReturnValue(mock<Logger>()) });
|
||||||
|
|
||||||
|
export * from './random';
|
||||||
|
export * as testDb from './test-db';
|
||||||
|
export * as testModules from './test-modules';
|
||||||
|
export * from './db/workflows';
|
||||||
|
export * from './db/projects';
|
||||||
|
export * from './mocking';
|
||||||
|
|||||||
12
packages/@n8n/backend-test-utils/src/mocking.ts
Normal file
12
packages/@n8n/backend-test-utils/src/mocking.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { Container, type Constructable } from '@n8n/di';
|
||||||
|
import { mock } from 'jest-mock-extended';
|
||||||
|
import type { DeepPartial } from 'ts-essentials';
|
||||||
|
|
||||||
|
export const mockInstance = <T>(
|
||||||
|
serviceClass: Constructable<T>,
|
||||||
|
data: DeepPartial<T> | undefined = undefined,
|
||||||
|
) => {
|
||||||
|
const instance = mock<T>(data);
|
||||||
|
Container.set(serviceClass, instance);
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
|
import { MIN_PASSWORD_CHAR_LENGTH, MAX_PASSWORD_CHAR_LENGTH } from '@n8n/constants';
|
||||||
import { randomInt, randomString, UPPERCASE_LETTERS } from 'n8n-workflow';
|
import { randomInt, randomString, UPPERCASE_LETTERS } from 'n8n-workflow';
|
||||||
|
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
import { MIN_PASSWORD_CHAR_LENGTH, MAX_PASSWORD_CHAR_LENGTH } from '@/constants';
|
export type CredentialPayload = {
|
||||||
|
name: string;
|
||||||
import type { CredentialPayload } from './types';
|
type: string;
|
||||||
|
data: ICredentialDataDecryptedObject;
|
||||||
|
isManaged?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export const randomApiKey = () => `n8n_api_${randomString(40)}`;
|
export const randomApiKey = () => `n8n_api_${randomString(40)}`;
|
||||||
|
|
||||||
@@ -29,14 +34,14 @@ export const randomInvalidPassword = () =>
|
|||||||
'abcdefg', // invalid length, no number, no uppercase
|
'abcdefg', // invalid length, no number, no uppercase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const randomEmail = () => `${randomName()}@${randomName()}.${randomTopLevelDomain()}`;
|
|
||||||
|
|
||||||
const POPULAR_TOP_LEVEL_DOMAINS = ['com', 'org', 'net', 'io', 'edu'];
|
const POPULAR_TOP_LEVEL_DOMAINS = ['com', 'org', 'net', 'io', 'edu'];
|
||||||
|
|
||||||
const randomTopLevelDomain = () => chooseRandomly(POPULAR_TOP_LEVEL_DOMAINS);
|
const randomTopLevelDomain = () => chooseRandomly(POPULAR_TOP_LEVEL_DOMAINS);
|
||||||
|
|
||||||
export const randomName = () => randomString(4, 8).toLowerCase();
|
export const randomName = () => randomString(4, 8).toLowerCase();
|
||||||
|
|
||||||
|
export const randomEmail = () => `${randomName()}@${randomName()}.${randomTopLevelDomain()}`;
|
||||||
|
|
||||||
export const randomCredentialPayload = ({
|
export const randomCredentialPayload = ({
|
||||||
isManaged = false,
|
isManaged = false,
|
||||||
}: { isManaged?: boolean } = {}): CredentialPayload => ({
|
}: { isManaged?: boolean } = {}): CredentialPayload => ({
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { entities } from '@n8n/db';
|
import type { entities } from '@n8n/db';
|
||||||
import { DbConnection } from '@n8n/db';
|
import { DbConnection, DbConnectionOptions } from '@n8n/db';
|
||||||
import { DbConnectionOptions } from '@n8n/db';
|
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type { DataSourceOptions } from '@n8n/typeorm';
|
import type { DataSourceOptions } from '@n8n/typeorm';
|
||||||
import { DataSource as Connection } from '@n8n/typeorm';
|
import { DataSource as Connection } from '@n8n/typeorm';
|
||||||
@@ -9,6 +8,21 @@ import { randomString } from 'n8n-workflow';
|
|||||||
|
|
||||||
export const testDbPrefix = 'n8n_test_';
|
export const testDbPrefix = 'n8n_test_';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate options for a bootstrap DB connection, to create and drop test databases.
|
||||||
|
*/
|
||||||
|
export const getBootstrapDBOptions = (dbType: 'postgresdb' | 'mysqldb'): DataSourceOptions => {
|
||||||
|
const globalConfig = Container.get(GlobalConfig);
|
||||||
|
const type = dbType === 'postgresdb' ? 'postgres' : 'mysql';
|
||||||
|
return {
|
||||||
|
type,
|
||||||
|
...Container.get(DbConnectionOptions).getOverrides(dbType),
|
||||||
|
database: type,
|
||||||
|
entityPrefix: globalConfig.database.tablePrefix,
|
||||||
|
schema: dbType === 'postgresdb' ? globalConfig.database.postgresdb.schema : undefined,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize one test DB per suite run, with bootstrap connection if needed.
|
* Initialize one test DB per suite run, with bootstrap connection if needed.
|
||||||
*/
|
*/
|
||||||
@@ -64,18 +78,3 @@ export async function truncate(entities: EntityName[]) {
|
|||||||
await connection.getRepository(name).delete({});
|
await connection.getRepository(name).delete({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate options for a bootstrap DB connection, to create and drop test databases.
|
|
||||||
*/
|
|
||||||
export const getBootstrapDBOptions = (dbType: 'postgresdb' | 'mysqldb'): DataSourceOptions => {
|
|
||||||
const globalConfig = Container.get(GlobalConfig);
|
|
||||||
const type = dbType === 'postgresdb' ? 'postgres' : 'mysql';
|
|
||||||
return {
|
|
||||||
type,
|
|
||||||
...Container.get(DbConnectionOptions).getOverrides(dbType),
|
|
||||||
database: type,
|
|
||||||
entityPrefix: globalConfig.database.tablePrefix,
|
|
||||||
schema: dbType === 'postgresdb' ? globalConfig.database.postgresdb.schema : undefined,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -103,3 +103,7 @@ export const LDAP_DEFAULT_CONFIGURATION: LdapConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export { Time } from './time';
|
export { Time } from './time';
|
||||||
|
|
||||||
|
export const MIN_PASSWORD_CHAR_LENGTH = 8;
|
||||||
|
|
||||||
|
export const MAX_PASSWORD_CHAR_LENGTH = 64;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@n8n/typescript-config": "workspace:*",
|
"@n8n/typescript-config": "workspace:*",
|
||||||
"@types/lodash": "catalog:"
|
"@types/lodash": "catalog:",
|
||||||
|
"express": "5.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { GlobalRole, Scope } from '@n8n/permissions';
|
import type { GlobalRole, Scope } from '@n8n/permissions';
|
||||||
import type { FindOperator } from '@n8n/typeorm';
|
import type { FindOperator } from '@n8n/typeorm';
|
||||||
|
import type express from 'express';
|
||||||
import type {
|
import type {
|
||||||
ICredentialsEncrypted,
|
ICredentialsEncrypted,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
@@ -356,3 +357,25 @@ export type WorkflowFolderUnionFull = (
|
|||||||
) & {
|
) & {
|
||||||
resource: ResourceType;
|
resource: ResourceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type APIRequest<
|
||||||
|
RouteParams = {},
|
||||||
|
ResponseBody = {},
|
||||||
|
RequestBody = {},
|
||||||
|
RequestQuery = {},
|
||||||
|
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery> & {
|
||||||
|
browserId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AuthenticatedRequest<
|
||||||
|
RouteParams = {},
|
||||||
|
ResponseBody = {},
|
||||||
|
RequestBody = {},
|
||||||
|
RequestQuery = {},
|
||||||
|
> = Omit<APIRequest<RouteParams, ResponseBody, RequestBody, RequestQuery>, 'user' | 'cookies'> & {
|
||||||
|
user: User;
|
||||||
|
cookies: Record<string, string | undefined>;
|
||||||
|
headers: express.Request['headers'] & {
|
||||||
|
'push-ref': string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export {
|
|||||||
export { generateNanoId } from './utils/generators';
|
export { generateNanoId } from './utils/generators';
|
||||||
export { isStringArray } from './utils/is-string-array';
|
export { isStringArray } from './utils/is-string-array';
|
||||||
export { separate } from './utils/separate';
|
export { separate } from './utils/separate';
|
||||||
|
export { sql } from './utils/sql';
|
||||||
export { idStringifier, lowerCaser, objectRetriever, sqlite } from './utils/transformers';
|
export { idStringifier, lowerCaser, objectRetriever, sqlite } from './utils/transformers';
|
||||||
|
|
||||||
export * from './entities';
|
export * from './entities';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { ExecutionRepository } from '@n8n/db';
|
import type { ExecutionRepository } from '@n8n/db';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { captor, mock } from 'jest-mock-extended';
|
import { captor, mock } from 'jest-mock-extended';
|
||||||
@@ -16,7 +17,6 @@ import { v4 as uuid } from 'uuid';
|
|||||||
import { ActiveExecutions } from '@/active-executions';
|
import { ActiveExecutions } from '@/active-executions';
|
||||||
import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service';
|
import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
jest.mock('n8n-workflow', () => ({
|
jest.mock('n8n-workflow', () => ({
|
||||||
...jest.requireActual('n8n-workflow'),
|
...jest.requireActual('n8n-workflow'),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { WorkflowEntity } from '@n8n/db';
|
import type { WorkflowEntity } from '@n8n/db';
|
||||||
import { ExecutionRepository } from '@n8n/db';
|
import { ExecutionRepository } from '@n8n/db';
|
||||||
@@ -29,7 +30,6 @@ import { WorkflowStatisticsService } from '@/services/workflow-statistics.servic
|
|||||||
import { Telemetry } from '@/telemetry';
|
import { Telemetry } from '@/telemetry';
|
||||||
import { executeWorkflow, getBase, getRunData } from '@/workflow-execute-additional-data';
|
import { executeWorkflow, getBase, getRunData } from '@/workflow-execute-additional-data';
|
||||||
import * as WorkflowHelpers from '@/workflow-helpers';
|
import * as WorkflowHelpers from '@/workflow-helpers';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
const EXECUTION_ID = '123';
|
const EXECUTION_ID = '123';
|
||||||
const LAST_NODE_EXECUTED = 'Last node executed';
|
const LAST_NODE_EXECUTED = 'Last node executed';
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { ExecutionEntity } from '@n8n/db';
|
import type { ExecutionEntity } from '@n8n/db';
|
||||||
import { Container, Service } from '@n8n/di';
|
import { Container, Service } from '@n8n/di';
|
||||||
@@ -29,11 +32,8 @@ import { ManualExecutionService } from '@/manual-execution.service';
|
|||||||
import { Telemetry } from '@/telemetry';
|
import { Telemetry } from '@/telemetry';
|
||||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||||
import { WorkflowRunner } from '@/workflow-runner';
|
import { WorkflowRunner } from '@/workflow-runner';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { createExecution } from '@test-integration/db/executions';
|
import { createExecution } from '@test-integration/db/executions';
|
||||||
import { createUser } from '@test-integration/db/users';
|
import { createUser } from '@test-integration/db/users';
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import { setupTestServer } from '@test-integration/utils';
|
import { setupTestServer } from '@test-integration/utils';
|
||||||
|
|
||||||
let owner: User;
|
let owner: User;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { GlobalConfig } from '@n8n/config';
|
import type { GlobalConfig } from '@n8n/config';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { InvalidAuthTokenRepository } from '@n8n/db';
|
import type { InvalidAuthTokenRepository } from '@n8n/db';
|
||||||
import type { UserRepository } from '@n8n/db';
|
import type { UserRepository } from '@n8n/db';
|
||||||
@@ -10,7 +11,6 @@ import jwt from 'jsonwebtoken';
|
|||||||
import { AuthService } from '@/auth/auth.service';
|
import { AuthService } from '@/auth/auth.service';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { AUTH_COOKIE_NAME } from '@/constants';
|
import { AUTH_COOKIE_NAME } from '@/constants';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { JwtService } from '@/services/jwt.service';
|
import { JwtService } from '@/services/jwt.service';
|
||||||
import type { UrlService } from '@/services/url.service';
|
import type { UrlService } from '@/services/url.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
import type { User } from '@n8n/db';
|
import type { AuthenticatedRequest, User } from '@n8n/db';
|
||||||
import { InvalidAuthTokenRepository, UserRepository } from '@n8n/db';
|
import { InvalidAuthTokenRepository, UserRepository } from '@n8n/db';
|
||||||
import { Service } from '@n8n/di';
|
import { Service } from '@n8n/di';
|
||||||
import { createHash } from 'crypto';
|
import { createHash } from 'crypto';
|
||||||
@@ -14,7 +14,6 @@ import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES } from '@/constants';
|
|||||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { JwtService } from '@/services/jwt.service';
|
import { JwtService } from '@/services/jwt.service';
|
||||||
import { UrlService } from '@/services/url.service';
|
import { UrlService } from '@/services/url.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { User, WorkflowEntity } from '@n8n/db';
|
import type { User, WorkflowEntity } from '@n8n/db';
|
||||||
import { WorkflowRepository } from '@n8n/db';
|
import { WorkflowRepository } from '@n8n/db';
|
||||||
@@ -19,7 +20,6 @@ import { OwnershipService } from '@/services/ownership.service';
|
|||||||
import { ShutdownService } from '@/shutdown/shutdown.service';
|
import { ShutdownService } from '@/shutdown/shutdown.service';
|
||||||
import { TaskRunnerModule } from '@/task-runners/task-runner-module';
|
import { TaskRunnerModule } from '@/task-runners/task-runner-module';
|
||||||
import { WorkflowRunner } from '@/workflow-runner';
|
import { WorkflowRunner } from '@/workflow-runner';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { ExecuteBatch } from '../execute-batch';
|
import { ExecuteBatch } from '../execute-batch';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { User, WorkflowEntity } from '@n8n/db';
|
import type { User, WorkflowEntity } from '@n8n/db';
|
||||||
import { WorkflowRepository } from '@n8n/db';
|
import { WorkflowRepository } from '@n8n/db';
|
||||||
@@ -18,7 +19,6 @@ import { OwnershipService } from '@/services/ownership.service';
|
|||||||
import { ShutdownService } from '@/shutdown/shutdown.service';
|
import { ShutdownService } from '@/shutdown/shutdown.service';
|
||||||
import { TaskRunnerModule } from '@/task-runners/task-runner-module';
|
import { TaskRunnerModule } from '@/task-runners/task-runner-module';
|
||||||
import { WorkflowRunner } from '@/workflow-runner';
|
import { WorkflowRunner } from '@/workflow-runner';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { Execute } from '../execute';
|
import { Execute } from '../execute';
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { IrreversibleMigration, ReversibleMigration } from '@n8n/db';
|
import type { IrreversibleMigration, ReversibleMigration } from '@n8n/db';
|
||||||
import type { Migration, MigrationExecutor } from '@n8n/typeorm';
|
import type { Migration, MigrationExecutor } from '@n8n/typeorm';
|
||||||
import { type DataSource } from '@n8n/typeorm';
|
import { type DataSource } from '@n8n/typeorm';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { main } from '@/commands/db/revert';
|
import { main } from '@/commands/db/revert';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
const logger = mockInstance(Logger);
|
const logger = mockInstance(Logger);
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,6 @@ export const CREDENTIAL_BLANKING_VALUE = '__n8n_BLANK_VALUE_e5362baf-c777-4d57-a
|
|||||||
export const UM_FIX_INSTRUCTION =
|
export const UM_FIX_INSTRUCTION =
|
||||||
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
||||||
|
|
||||||
export const MIN_PASSWORD_CHAR_LENGTH = 8;
|
|
||||||
|
|
||||||
export const MAX_PASSWORD_CHAR_LENGTH = 64;
|
|
||||||
|
|
||||||
export const TEST_WEBHOOK_TIMEOUT = 2 * Time.minutes.toMilliseconds;
|
export const TEST_WEBHOOK_TIMEOUT = 2 * Time.minutes.toMilliseconds;
|
||||||
|
|
||||||
export const TEST_WEBHOOK_TIMEOUT_BUFFER = 30 * Time.seconds.toMilliseconds;
|
export const TEST_WEBHOOK_TIMEOUT_BUFFER = 30 * Time.seconds.toMilliseconds;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { inProduction } from '@n8n/backend-common';
|
import { inProduction } from '@n8n/backend-common';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import { type BooleanLicenseFeature } from '@n8n/constants';
|
import { type BooleanLicenseFeature } from '@n8n/constants';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { ControllerRegistryMetadata } from '@n8n/decorators';
|
import { ControllerRegistryMetadata } from '@n8n/decorators';
|
||||||
import type { AccessScope, Controller, RateLimit } from '@n8n/decorators';
|
import type { AccessScope, Controller, RateLimit } from '@n8n/decorators';
|
||||||
import { Container, Service } from '@n8n/di';
|
import { Container, Service } from '@n8n/di';
|
||||||
@@ -15,7 +16,6 @@ import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
|||||||
import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error';
|
import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { userHasScopes } from '@/permissions.ee/check-access';
|
import { userHasScopes } from '@/permissions.ee/check-access';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { send } from '@/response-helper'; // TODO: move `ResponseHelper.send` to this file
|
import { send } from '@/response-helper'; // TODO: move `ResponseHelper.send` to this file
|
||||||
|
|
||||||
import { NotFoundError } from './errors/response-errors/not-found.error';
|
import { NotFoundError } from './errors/response-errors/not-found.error';
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import type {
|
|||||||
AiApplySuggestionRequestDto,
|
AiApplySuggestionRequestDto,
|
||||||
AiChatRequestDto,
|
AiChatRequestDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import type { WorkflowBuilderService } from '@/services/ai-workflow-builder.service';
|
import type { WorkflowBuilderService } from '@/services/ai-workflow-builder.service';
|
||||||
import type { AiService } from '@/services/ai.service';
|
import type { AiService } from '@/services/ai.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { ApiKey } from '@n8n/db';
|
import type { ApiKey } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { ApiKeysController } from '../api-keys.controller';
|
import { ApiKeysController } from '../api-keys.controller';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import type { LoginRequestDto } from '@n8n/api-types';
|
import type { LoginRequestDto } from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import { UserRepository } from '@n8n/db';
|
import { UserRepository } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
@@ -14,9 +16,7 @@ import { LdapService } from '@/ldap.ee/ldap.service.ee';
|
|||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { AuthController } from '../auth.controller';
|
import { AuthController } from '../auth.controller';
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type {
|
|||||||
ResourceMapperFieldsRequestDto,
|
ResourceMapperFieldsRequestDto,
|
||||||
ActionResultRequestDto,
|
ActionResultRequestDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import type {
|
import type {
|
||||||
ILoadOptions,
|
ILoadOptions,
|
||||||
@@ -13,7 +14,6 @@ import type {
|
|||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { DynamicNodeParametersController } from '@/controllers/dynamic-node-parameters.controller';
|
import { DynamicNodeParametersController } from '@/controllers/dynamic-node-parameters.controller';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import type { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
|
import type { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
|
||||||
import * as AdditionalData from '@/workflow-execute-additional-data';
|
import * as AdditionalData from '@/workflow-execute-additional-data';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { UserUpdateRequestDto } from '@n8n/api-types';
|
import { UserUpdateRequestDto } from '@n8n/api-types';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { PublicUser } from '@n8n/db';
|
import type { PublicUser } from '@n8n/db';
|
||||||
import { InvalidAuthTokenRepository } from '@n8n/db';
|
import { InvalidAuthTokenRepository } from '@n8n/db';
|
||||||
@@ -16,9 +18,8 @@ import { EventService } from '@/events/event.service';
|
|||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import type { AuthenticatedRequest, MeRequest } from '@/requests';
|
import type { MeRequest } from '@/requests';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { badPasswords } from '@test/test-data';
|
import { badPasswords } from '@test/test-data';
|
||||||
|
|
||||||
const browserId = 'test-browser-id';
|
const browserId = 'test-browser-id';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types';
|
import type { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types';
|
||||||
import type { Logger } from '@n8n/backend-common';
|
import type { Logger } from '@n8n/backend-common';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { PublicUser, SettingsRepository } from '@n8n/db';
|
import type { PublicUser, SettingsRepository } from '@n8n/db';
|
||||||
import type { UserRepository } from '@n8n/db';
|
import type { UserRepository } from '@n8n/db';
|
||||||
@@ -11,7 +12,6 @@ import config from '@/config';
|
|||||||
import { OwnerController } from '@/controllers/owner.controller';
|
import { OwnerController } from '@/controllers/owner.controller';
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import type { BannerService } from '@/services/banner.service';
|
import type { BannerService } from '@/services/banner.service';
|
||||||
import type { PasswordUtility } from '@/services/password.utility';
|
import type { PasswordUtility } from '@/services/password.utility';
|
||||||
import type { UserService } from '@/services/user.service';
|
import type { UserService } from '@/services/user.service';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { UserRepository } from '@n8n/db';
|
import type { UserRepository } from '@n8n/db';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import type { ProjectService } from '@/services/project.service.ee';
|
import type { ProjectService } from '@/services/project.service.ee';
|
||||||
|
|
||||||
import { UsersController } from '../users.controller';
|
import { UsersController } from '../users.controller';
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
AiFreeCreditsRequestDto,
|
AiFreeCreditsRequestDto,
|
||||||
AiBuilderChatRequestDto,
|
AiBuilderChatRequestDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Body, Post, RestController } from '@n8n/decorators';
|
import { Body, Post, RestController } from '@n8n/decorators';
|
||||||
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
@@ -16,7 +17,6 @@ import { WritableStream } from 'node:stream/web';
|
|||||||
import { FREE_AI_CREDITS_CREDENTIAL_NAME } from '@/constants';
|
import { FREE_AI_CREDITS_CREDENTIAL_NAME } from '@/constants';
|
||||||
import { CredentialsService } from '@/credentials/credentials.service';
|
import { CredentialsService } from '@/credentials/credentials.service';
|
||||||
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { WorkflowBuilderService } from '@/services/ai-workflow-builder.service';
|
import { WorkflowBuilderService } from '@/services/ai-workflow-builder.service';
|
||||||
import { AiService } from '@/services/ai.service';
|
import { AiService } from '@/services/ai.service';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { CreateApiKeyRequestDto, UpdateApiKeyRequestDto } from '@n8n/api-types';
|
import { CreateApiKeyRequestDto, UpdateApiKeyRequestDto } from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Body, Delete, Get, Param, Patch, Post, RestController } from '@n8n/decorators';
|
import { Body, Delete, Get, Param, Patch, Post, RestController } from '@n8n/decorators';
|
||||||
import { getApiKeyScopesForRole } from '@n8n/permissions';
|
import { getApiKeyScopesForRole } from '@n8n/permissions';
|
||||||
import type { RequestHandler } from 'express';
|
import type { RequestHandler } from 'express';
|
||||||
@@ -6,7 +7,6 @@ import type { RequestHandler } from 'express';
|
|||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { isApiEnabled } from '@/public-api';
|
import { isApiEnabled } from '@/public-api';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
||||||
|
|
||||||
export const isApiEnabledMiddleware: RequestHandler = (_, res, next) => {
|
export const isApiEnabledMiddleware: RequestHandler = (_, res, next) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LoginRequestDto, ResolveSignupTokenQueryDto } from '@n8n/api-types';
|
import { LoginRequestDto, ResolveSignupTokenQueryDto } from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import type { User, PublicUser } from '@n8n/db';
|
import type { User, PublicUser } from '@n8n/db';
|
||||||
import { UserRepository } from '@n8n/db';
|
import { UserRepository, AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Body, Get, Post, Query, RestController } from '@n8n/decorators';
|
import { Body, Get, Post, Query, RestController } from '@n8n/decorators';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { isEmail } from 'class-validator';
|
import { isEmail } from 'class-validator';
|
||||||
@@ -17,7 +17,7 @@ import { EventService } from '@/events/event.service';
|
|||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import { AuthenticatedRequest, AuthlessRequest } from '@/requests';
|
import { AuthlessRequest } from '@/requests';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import {
|
import {
|
||||||
getCurrentAuthenticationMethod,
|
getCurrentAuthenticationMethod,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Get, RestController } from '@n8n/decorators';
|
import { Get, RestController } from '@n8n/decorators';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { CtaService } from '@/services/cta.service';
|
import { CtaService } from '@/services/cta.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
ResourceMapperFieldsRequestDto,
|
ResourceMapperFieldsRequestDto,
|
||||||
ActionResultRequestDto,
|
ActionResultRequestDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Post, RestController, Body } from '@n8n/decorators';
|
import { Post, RestController, Body } from '@n8n/decorators';
|
||||||
import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow';
|
import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
|
import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service';
|
||||||
import { getBase } from '@/workflow-execute-additional-data';
|
import { getBase } from '@/workflow-execute-additional-data';
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
TransferFolderBodyDto,
|
TransferFolderBodyDto,
|
||||||
UpdateFolderDto,
|
UpdateFolderDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
Post,
|
Post,
|
||||||
RestController,
|
RestController,
|
||||||
@@ -24,7 +25,6 @@ import { FolderNotFoundError } from '@/errors/folder-not-found.error';
|
|||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { FolderService } from '@/services/folder.service';
|
import { FolderService } from '@/services/folder.service';
|
||||||
import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee';
|
import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AcceptInvitationRequestDto, InviteUsersRequestDto } from '@n8n/api-types';
|
import { AcceptInvitationRequestDto, InviteUsersRequestDto } from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import { UserRepository } from '@n8n/db';
|
import { UserRepository, AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Post, GlobalScope, RestController, Body, Param } from '@n8n/decorators';
|
import { Post, GlobalScope, RestController, Body, Param } from '@n8n/decorators';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import { EventService } from '@/events/event.service';
|
|||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import { AuthenticatedRequest, AuthlessRequest } from '@/requests';
|
import { AuthlessRequest } from '@/requests';
|
||||||
import { PasswordUtility } from '@/services/password.utility';
|
import { PasswordUtility } from '@/services/password.utility';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers';
|
import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import type { User, PublicUser } from '@n8n/db';
|
import type { User, PublicUser } from '@n8n/db';
|
||||||
import { UserRepository } from '@n8n/db';
|
import { UserRepository, AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Body, Patch, Post, RestController } from '@n8n/decorators';
|
import { Body, Patch, Post, RestController } from '@n8n/decorators';
|
||||||
import { plainToInstance } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
@@ -18,7 +18,7 @@ import { EventService } from '@/events/event.service';
|
|||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { validateEntity } from '@/generic-helpers';
|
import { validateEntity } from '@/generic-helpers';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import { AuthenticatedRequest, MeRequest } from '@/requests';
|
import { MeRequest } from '@/requests';
|
||||||
import { PasswordUtility } from '@/services/password.utility';
|
import { PasswordUtility } from '@/services/password.utility';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers';
|
import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { UserRepository } from '@n8n/db';
|
import { AuthenticatedRequest, UserRepository } from '@n8n/db';
|
||||||
import { Get, Post, RestController } from '@n8n/decorators';
|
import { Get, Post, RestController } from '@n8n/decorators';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ import { AuthService } from '@/auth/auth.service';
|
|||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import { AuthenticatedRequest, MFA } from '@/requests';
|
import { MFA } from '@/requests';
|
||||||
|
|
||||||
@RestController('/mfa')
|
@RestController('/mfa')
|
||||||
export class MFAController {
|
export class MFAController {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
import type { CredentialsEntity } from '@n8n/db';
|
import type { CredentialsEntity } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
@@ -20,7 +21,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
|||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import type { OAuthRequest } from '@/requests';
|
import type { OAuthRequest } from '@/requests';
|
||||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
jest.mock('@/workflow-execute-additional-data');
|
jest.mock('@/workflow-execute-additional-data');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
import type { CredentialsEntity } from '@n8n/db';
|
import type { CredentialsEntity } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
@@ -21,7 +22,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
|||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import type { OAuthRequest } from '@/requests';
|
import type { OAuthRequest } from '@/requests';
|
||||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
jest.mock('@/workflow-execute-additional-data');
|
jest.mock('@/workflow-execute-additional-data');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
import type { CredentialsEntity, ICredentialsDb } from '@n8n/db';
|
import type { AuthenticatedRequest, CredentialsEntity, ICredentialsDb } from '@n8n/db';
|
||||||
import { CredentialsRepository } from '@n8n/db';
|
import { CredentialsRepository } from '@n8n/db';
|
||||||
import { Service } from '@n8n/di';
|
import { Service } from '@n8n/di';
|
||||||
import Csrf from 'csrf';
|
import Csrf from 'csrf';
|
||||||
@@ -17,7 +17,7 @@ import { AuthError } from '@/errors/response-errors/auth.error';
|
|||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import type { AuthenticatedRequest, OAuthRequest } from '@/requests';
|
import type { OAuthRequest } from '@/requests';
|
||||||
import { UrlService } from '@/services/url.service';
|
import { UrlService } from '@/services/url.service';
|
||||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types';
|
import { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import { SettingsRepository, UserRepository } from '@n8n/db';
|
import { AuthenticatedRequest, SettingsRepository, UserRepository } from '@n8n/db';
|
||||||
import { Body, GlobalScope, Post, RestController } from '@n8n/decorators';
|
import { Body, GlobalScope, Post, RestController } from '@n8n/decorators';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
|||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { validateEntity } from '@/generic-helpers';
|
import { validateEntity } from '@/generic-helpers';
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { BannerService } from '@/services/banner.service';
|
import { BannerService } from '@/services/banner.service';
|
||||||
import { PasswordUtility } from '@/services/password.utility';
|
import { PasswordUtility } from '@/services/password.utility';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CreateProjectDto, DeleteProjectDto, UpdateProjectDto } from '@n8n/api-types';
|
import { CreateProjectDto, DeleteProjectDto, UpdateProjectDto } from '@n8n/api-types';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import { ProjectRepository } from '@n8n/db';
|
import { AuthenticatedRequest, ProjectRepository } from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
Get,
|
Get,
|
||||||
Post,
|
Post,
|
||||||
@@ -24,7 +24,6 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
|||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import type { ProjectRequest } from '@/requests';
|
import type { ProjectRequest } from '@/requests';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import {
|
import {
|
||||||
ProjectService,
|
ProjectService,
|
||||||
TeamProjectOverQuotaError,
|
TeamProjectOverQuotaError,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { CreateOrUpdateTagRequestDto, RetrieveTagQueryDto } from '@n8n/api-types';
|
import { CreateOrUpdateTagRequestDto, RetrieveTagQueryDto } from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
@@ -12,7 +13,6 @@ import {
|
|||||||
} from '@n8n/decorators';
|
} from '@n8n/decorators';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { TagService } from '@/services/tag.service';
|
import { TagService } from '@/services/tag.service';
|
||||||
|
|
||||||
@RestController('/tags')
|
@RestController('/tags')
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
SharedCredentialsRepository,
|
SharedCredentialsRepository,
|
||||||
SharedWorkflowRepository,
|
SharedWorkflowRepository,
|
||||||
UserRepository,
|
UserRepository,
|
||||||
|
AuthenticatedRequest,
|
||||||
} from '@n8n/db';
|
} from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
GlobalScope,
|
GlobalScope,
|
||||||
@@ -35,7 +36,7 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
|||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { AuthenticatedRequest, UserRequest } from '@/requests';
|
import { UserRequest } from '@/requests';
|
||||||
import { FolderService } from '@/services/folder.service';
|
import { FolderService } from '@/services/folder.service';
|
||||||
import { ProjectService } from '@/services/project.service.ee';
|
import { ProjectService } from '@/services/project.service.ee';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { SharedCredentialsRepository } from '@n8n/db';
|
import type { SharedCredentialsRepository } from '@n8n/db';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { createRawProjectData } from '@/__tests__/project.test-data';
|
import { createRawProjectData } from '@/__tests__/project.test-data';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { createdCredentialsWithScopes, createNewCredentialsPayload } from './credentials.test-data';
|
import { createdCredentialsWithScopes, createNewCredentialsPayload } from './credentials.test-data';
|
||||||
import { CredentialsController } from '../credentials.controller';
|
import { CredentialsController } from '../credentials.controller';
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import {
|
|||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import { SharedCredentials, ProjectRelationRepository, SharedCredentialsRepository } from '@n8n/db';
|
import {
|
||||||
|
SharedCredentials,
|
||||||
|
ProjectRelationRepository,
|
||||||
|
SharedCredentialsRepository,
|
||||||
|
AuthenticatedRequest,
|
||||||
|
} from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
@@ -32,7 +37,7 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
|||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { listQueryMiddleware } from '@/middlewares';
|
import { listQueryMiddleware } from '@/middlewares';
|
||||||
import { AuthenticatedRequest, CredentialRequest } from '@/requests';
|
import { CredentialRequest } from '@/requests';
|
||||||
import { NamingService } from '@/services/naming.service';
|
import { NamingService } from '@/services/naming.service';
|
||||||
import { UserManagementMailer } from '@/user-management/email';
|
import { UserManagementMailer } from '@/user-management/email';
|
||||||
import * as utils from '@/utils';
|
import * as utils from '@/utils';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { SqliteConfig } from '@n8n/config/src/configs/database.config';
|
import type { SqliteConfig } from '@n8n/config/src/configs/database.config';
|
||||||
import type { IExecutionResponse } from '@n8n/db';
|
import type { IExecutionResponse } from '@n8n/db';
|
||||||
@@ -11,7 +12,7 @@ import { BinaryDataService } from 'n8n-core';
|
|||||||
import type { IRunExecutionData, IWorkflowBase } from 'n8n-workflow';
|
import type { IRunExecutionData, IWorkflowBase } from 'n8n-workflow';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
import { mockInstance, mockEntityManager } from '@test/mocking';
|
import { mockEntityManager } from '@test/mocking';
|
||||||
|
|
||||||
describe('ExecutionRepository', () => {
|
describe('ExecutionRepository', () => {
|
||||||
const entityManager = mockEntityManager(ExecutionEntity);
|
const entityManager = mockEntityManager(ExecutionEntity);
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { getPersonalProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { Folder } from '@n8n/db';
|
import type { Folder } from '@n8n/db';
|
||||||
@@ -6,12 +9,8 @@ import { Container } from '@n8n/di';
|
|||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import { createFolder } from '@test-integration/db/folders';
|
import { createFolder } from '@test-integration/db/folders';
|
||||||
import { getPersonalProject } from '@test-integration/db/projects';
|
|
||||||
import { createTag } from '@test-integration/db/tags';
|
import { createTag } from '@test-integration/db/tags';
|
||||||
import { createMember, createOwner } from '@test-integration/db/users';
|
import { createMember, createOwner } from '@test-integration/db/users';
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
|
|
||||||
import * as testDb from '../../../../test/integration/shared/test-db';
|
|
||||||
|
|
||||||
describe('FolderRepository', () => {
|
describe('FolderRepository', () => {
|
||||||
let folderRepository: FolderRepository;
|
let folderRepository: FolderRepository;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
import { StatisticsNames, WorkflowStatistics } from '@n8n/db';
|
import { StatisticsNames, WorkflowStatistics } from '@n8n/db';
|
||||||
import { WorkflowStatisticsRepository } from '@n8n/db';
|
import { WorkflowStatisticsRepository } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
@@ -5,8 +7,6 @@ import { type InsertResult, QueryFailedError } from '@n8n/typeorm';
|
|||||||
import { mock, mockClear } from 'jest-mock-extended';
|
import { mock, mockClear } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { mockEntityManager } from '@test/mocking';
|
import { mockEntityManager } from '@test/mocking';
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
|
|
||||||
describe('insertWorkflowStatistics', () => {
|
describe('insertWorkflowStatistics', () => {
|
||||||
const entityManager = mockEntityManager(WorkflowStatistics);
|
const entityManager = mockEntityManager(WorkflowStatistics);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { Logger } from '@n8n/backend-common';
|
import type { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { InstanceType } from '@n8n/constants';
|
import type { InstanceType } from '@n8n/constants';
|
||||||
import { captor, mock } from 'jest-mock-extended';
|
import { captor, mock } from 'jest-mock-extended';
|
||||||
import { InstanceSettings } from 'n8n-core';
|
import { InstanceSettings } from 'n8n-core';
|
||||||
|
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { DeprecationService } from '../deprecation.service';
|
import { DeprecationService } from '../deprecation.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { PullWorkFolderRequestDto, PushWorkFolderRequestDto } from '@n8n/api-types';
|
import type { PullWorkFolderRequestDto, PushWorkFolderRequestDto } from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import type { SourceControlPreferencesService } from '../source-control-preferences.service.ee';
|
import type { SourceControlPreferencesService } from '../source-control-preferences.service.ee';
|
||||||
import { SourceControlController } from '../source-control.controller.ee';
|
import { SourceControlController } from '../source-control.controller.ee';
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { ProjectRepository, WorkflowRepository } from '@n8n/db';
|
||||||
import {
|
import {
|
||||||
|
type AuthenticatedRequest,
|
||||||
type CredentialsEntity,
|
type CredentialsEntity,
|
||||||
type Folder,
|
type Folder,
|
||||||
type Project,
|
type Project,
|
||||||
ProjectRepository,
|
|
||||||
type WorkflowEntity,
|
type WorkflowEntity,
|
||||||
WorkflowRepository,
|
|
||||||
type WorkflowTagMapping,
|
type WorkflowTagMapping,
|
||||||
} from '@n8n/db';
|
} from '@n8n/db';
|
||||||
import { Service } from '@n8n/di';
|
import { Service } from '@n8n/di';
|
||||||
@@ -13,7 +13,6 @@ import { hasGlobalScope } from '@n8n/permissions';
|
|||||||
import type { FindOptionsWhere } from '@n8n/typeorm';
|
import type { FindOptionsWhere } from '@n8n/typeorm';
|
||||||
|
|
||||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { SourceControlContext } from './types/source-control-context';
|
import { SourceControlContext } from './types/source-control-context';
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { PullWorkFolderRequestDto, PushWorkFolderRequestDto } from '@n8n/api-types';
|
import { PullWorkFolderRequestDto, PushWorkFolderRequestDto } from '@n8n/api-types';
|
||||||
import type { SourceControlledFile } from '@n8n/api-types';
|
import type { SourceControlledFile } from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Get, Post, Patch, RestController, GlobalScope, Body } from '@n8n/decorators';
|
import { Get, Post, Patch, RestController, GlobalScope, Body } from '@n8n/decorators';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import type { PullResult } from 'simple-git';
|
import type { PullResult } from 'simple-git';
|
||||||
|
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { SOURCE_CONTROL_DEFAULT_BRANCH } from './constants';
|
import { SOURCE_CONTROL_DEFAULT_BRANCH } from './constants';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { AuthenticatedRequest } from '@/requests';
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
|
|
||||||
import type { SourceControlCommit } from './source-control-commit';
|
import type { SourceControlCommit } from './source-control-commit';
|
||||||
import type { SourceControlDisconnect } from './source-control-disconnect';
|
import type { SourceControlDisconnect } from './source-control-disconnect';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { TestRun } from '@n8n/db';
|
import type { TestRun } from '@n8n/db';
|
||||||
import type { TestCaseExecutionRepository } from '@n8n/db';
|
import type { TestCaseExecutionRepository } from '@n8n/db';
|
||||||
import type { TestRunRepository } from '@n8n/db';
|
import type { TestRunRepository } from '@n8n/db';
|
||||||
@@ -18,7 +19,6 @@ import { TestRunError } from '@/evaluation.ee/test-runner/errors.ee';
|
|||||||
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
||||||
import type { Telemetry } from '@/telemetry';
|
import type { Telemetry } from '@/telemetry';
|
||||||
import type { WorkflowRunner } from '@/workflow-runner';
|
import type { WorkflowRunner } from '@/workflow-runner';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { mockNodeTypesData } from '@test-integration/utils/node-types-data';
|
import { mockNodeTypesData } from '@test-integration/utils/node-types-data';
|
||||||
|
|
||||||
import { TestRunnerService } from '../test-runner.service.ee';
|
import { TestRunnerService } from '../test-runner.service.ee';
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { AuthenticatedRequest, ListQuery } from '@/requests';
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
|
|
||||||
|
import type { ListQuery } from '@/requests';
|
||||||
|
|
||||||
export declare namespace TestRunsRequest {
|
export declare namespace TestRunsRequest {
|
||||||
namespace RouteParams {
|
namespace RouteParams {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { RestController, Get, Post, Delete, GlobalScope, Licensed } from '@n8n/decorators';
|
import { RestController, Get, Post, Delete, GlobalScope, Licensed } from '@n8n/decorators';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import type {
|
import type {
|
||||||
@@ -7,7 +8,6 @@ import type {
|
|||||||
import { MessageEventBusDestinationTypeNames } from 'n8n-workflow';
|
import { MessageEventBusDestinationTypeNames } from 'n8n-workflow';
|
||||||
|
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { eventNamesAll } from './event-message-classes';
|
import { eventNamesAll } from './event-message-classes';
|
||||||
import { MessageEventBus } from './message-event-bus/message-event-bus';
|
import { MessageEventBus } from './message-event-bus/message-event-bus';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { GlobalConfig } from '@n8n/config';
|
import type { GlobalConfig } from '@n8n/config';
|
||||||
import type { CredentialsEntity } from '@n8n/db';
|
import type { CredentialsEntity } from '@n8n/db';
|
||||||
import type { WorkflowEntity } from '@n8n/db';
|
import type { WorkflowEntity } from '@n8n/db';
|
||||||
@@ -18,7 +19,6 @@ import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay';
|
|||||||
import type { License } from '@/license';
|
import type { License } from '@/license';
|
||||||
import type { NodeTypes } from '@/node-types';
|
import type { NodeTypes } from '@/node-types';
|
||||||
import type { Telemetry } from '@/telemetry';
|
import type { Telemetry } from '@/telemetry';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
const flushPromises = async () => await new Promise((resolve) => setImmediate(resolve));
|
const flushPromises = async () => await new Promise((resolve) => setImmediate(resolve));
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Get, RestController } from '@n8n/decorators';
|
import { Get, RestController } from '@n8n/decorators';
|
||||||
|
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { EventService } from './event.service';
|
import { EventService } from './event.service';
|
||||||
|
|
||||||
/** This controller holds endpoints that the frontend uses to trigger telemetry events */
|
/** This controller holds endpoints that the frontend uses to trigger telemetry events */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import { ExecutionRepository } from '@n8n/db';
|
import { ExecutionRepository } from '@n8n/db';
|
||||||
import { stringify } from 'flatted';
|
import { stringify } from 'flatted';
|
||||||
@@ -30,7 +31,6 @@ import { OwnershipService } from '@/services/ownership.service';
|
|||||||
import { WorkflowStatisticsService } from '@/services/workflow-statistics.service';
|
import { WorkflowStatisticsService } from '@/services/workflow-statistics.service';
|
||||||
import { WorkflowExecutionService } from '@/workflows/workflow-execution.service';
|
import { WorkflowExecutionService } from '@/workflows/workflow-execution.service';
|
||||||
import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service';
|
import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLifecycleHooksForSubExecutions,
|
getLifecycleHooksForSubExecutions,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { BinaryDataConfig, BinaryDataService } from 'n8n-core';
|
import { BinaryDataConfig, BinaryDataService } from 'n8n-core';
|
||||||
import type { IRun } from 'n8n-workflow';
|
import type { IRun } from 'n8n-workflow';
|
||||||
|
|
||||||
import { restoreBinaryDataId } from '@/execution-lifecycle/restore-binary-data-id';
|
import { restoreBinaryDataId } from '@/execution-lifecycle/restore-binary-data-id';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
function toIRun(item?: object) {
|
function toIRun(item?: object) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { IExecutionResponse } from '@n8n/db';
|
import type { IExecutionResponse } from '@n8n/db';
|
||||||
import { ExecutionRepository } from '@n8n/db';
|
import { ExecutionRepository } from '@n8n/db';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import { ErrorReporter } from 'n8n-core';
|
import { ErrorReporter } from 'n8n-core';
|
||||||
import type { IRunExecutionData, ITaskData } from 'n8n-workflow';
|
import type { IRunExecutionData, ITaskData } from 'n8n-workflow';
|
||||||
|
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { saveExecutionProgress } from '../save-execution-progress';
|
import { saveExecutionProgress } from '../save-execution-progress';
|
||||||
|
|
||||||
describe('saveExecutionProgress', () => {
|
describe('saveExecutionProgress', () => {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { ExecutionRepository } from '@n8n/db';
|
import { ExecutionRepository } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { stringify } from 'flatted';
|
import { stringify } from 'flatted';
|
||||||
@@ -13,10 +16,7 @@ import type { EventMessageTypes as EventMessage } from '@/eventbus/event-message
|
|||||||
import { EventMessageNode } from '@/eventbus/event-message-classes/event-message-node';
|
import { EventMessageNode } from '@/eventbus/event-message-classes/event-message-node';
|
||||||
import { ExecutionRecoveryService } from '@/executions/execution-recovery.service';
|
import { ExecutionRecoveryService } from '@/executions/execution-recovery.service';
|
||||||
import { Push } from '@/push';
|
import { Push } from '@/push';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { createExecution } from '@test-integration/db/executions';
|
import { createExecution } from '@test-integration/db/executions';
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
|
|
||||||
import { IN_PROGRESS_EXECUTION_DATA, OOM_WORKFLOW } from './constants';
|
import { IN_PROGRESS_EXECUTION_DATA, OOM_WORKFLOW } from './constants';
|
||||||
import { setupMessages } from './utils';
|
import { setupMessages } from './utils';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { IExecutionResponse } from '@n8n/db';
|
import type { IExecutionResponse } from '@n8n/db';
|
||||||
import type { ExecutionRepository } from '@n8n/db';
|
import type { ExecutionRepository } from '@n8n/db';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
@@ -13,7 +14,6 @@ import type { ExecutionRequest } from '@/executions/execution.types';
|
|||||||
import { ScalingService } from '@/scaling/scaling.service';
|
import { ScalingService } from '@/scaling/scaling.service';
|
||||||
import type { Job } from '@/scaling/scaling.types';
|
import type { Job } from '@/scaling/scaling.types';
|
||||||
import type { WaitTracker } from '@/wait-tracker';
|
import type { WaitTracker } from '@/wait-tracker';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
describe('ExecutionService', () => {
|
describe('ExecutionService', () => {
|
||||||
const scalingService = mockInstance(ScalingService);
|
const scalingService = mockInstance(ScalingService);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ExecutionSummaries, ExecutionEntity } from '@n8n/db';
|
import type { AuthenticatedRequest, ExecutionSummaries, ExecutionEntity } from '@n8n/db';
|
||||||
import type {
|
import type {
|
||||||
AnnotationVote,
|
AnnotationVote,
|
||||||
ExecutionStatus,
|
ExecutionStatus,
|
||||||
@@ -6,8 +6,6 @@ import type {
|
|||||||
WorkflowExecuteMode,
|
WorkflowExecuteMode,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
export declare namespace ExecutionRequest {
|
export declare namespace ExecutionRequest {
|
||||||
namespace QueryParams {
|
namespace QueryParams {
|
||||||
type GetMany = {
|
type GetMany = {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { GlobalConfig } from '@n8n/config';
|
import type { GlobalConfig } from '@n8n/config';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
@@ -13,7 +14,6 @@ import {
|
|||||||
import type { AccessService } from '@/services/access.service';
|
import type { AccessService } from '@/services/access.service';
|
||||||
import { OwnershipService } from '@/services/ownership.service';
|
import { OwnershipService } from '@/services/ownership.service';
|
||||||
import type { UrlService } from '@/services/url.service';
|
import type { UrlService } from '@/services/url.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker';
|
import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker';
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { generateNanoId } from '@n8n/db';
|
import { generateNanoId } from '@n8n/db';
|
||||||
import { AuthIdentity } from '@n8n/db';
|
import { AuthIdentity } from '@n8n/db';
|
||||||
import { User } from '@n8n/db';
|
import { User } from '@n8n/db';
|
||||||
import { UserRepository } from '@n8n/db';
|
import { UserRepository } from '@n8n/db';
|
||||||
|
|
||||||
import * as helpers from '@/ldap.ee/helpers.ee';
|
import * as helpers from '@/ldap.ee/helpers.ee';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
const userRepository = mockInstance(UserRepository);
|
const userRepository = mockInstance(UserRepository);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { LDAP_FEATURE_NAME, type LdapConfig } from '@n8n/constants';
|
import { LDAP_FEATURE_NAME, type LdapConfig } from '@n8n/constants';
|
||||||
import type { Settings } from '@n8n/db';
|
import type { Settings } from '@n8n/db';
|
||||||
import { AuthIdentityRepository, SettingsRepository } from '@n8n/db';
|
import { AuthIdentityRepository, SettingsRepository } from '@n8n/db';
|
||||||
@@ -10,7 +11,6 @@ import { randomString } from 'n8n-workflow';
|
|||||||
|
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { BINARY_AD_ATTRIBUTES, LDAP_LOGIN_ENABLED, LDAP_LOGIN_LABEL } from '../constants';
|
import { BINARY_AD_ATTRIBUTES, LDAP_LOGIN_ENABLED, LDAP_LOGIN_LABEL } from '../constants';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import type { LdapConfig } from '@n8n/constants';
|
import type { LdapConfig } from '@n8n/constants';
|
||||||
import type { RunningMode } from '@n8n/db';
|
import type { AuthenticatedRequest, RunningMode } from '@n8n/db';
|
||||||
|
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
export declare namespace LdapConfiguration {
|
export declare namespace LdapConfiguration {
|
||||||
type Update = AuthenticatedRequest<{}, {}, LdapConfig, {}>;
|
type Update = AuthenticatedRequest<{}, {}, LdapConfig, {}>;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { CommunityRegisteredRequestDto } from '@n8n/api-types';
|
import { CommunityRegisteredRequestDto } from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Get, Post, RestController, GlobalScope, Body } from '@n8n/decorators';
|
import { Get, Post, RestController, GlobalScope, Body } from '@n8n/decorators';
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
import { InstanceSettings } from 'n8n-core';
|
import { InstanceSettings } from 'n8n-core';
|
||||||
|
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { AuthenticatedRequest, LicenseRequest } from '@/requests';
|
import { LicenseRequest } from '@/requests';
|
||||||
import { UrlService } from '@/services/url.service';
|
import { UrlService } from '@/services/url.service';
|
||||||
|
|
||||||
import { LicenseService } from './license.service';
|
import { LicenseService } from './license.service';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { WorkflowRepository } from '@n8n/db';
|
import type { WorkflowRepository } from '@n8n/db';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
@@ -9,7 +10,6 @@ import promClient from 'prom-client';
|
|||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { PrometheusMetricsService } from '../prometheus-metrics.service';
|
import { PrometheusMetricsService } from '../prometheus-metrics.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type { WorkflowRepository } from '@n8n/db';
|
import type { WorkflowRepository } from '@n8n/db';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
@@ -8,7 +9,6 @@ import promClient from 'prom-client';
|
|||||||
import { EventMessageWorkflow } from '@/eventbus/event-message-classes/event-message-workflow';
|
import { EventMessageWorkflow } from '@/eventbus/event-message-classes/event-message-workflow';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { CacheService } from '@/services/cache/cache.service';
|
import type { CacheService } from '@/services/cache/cache.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { MessageEventBus } from '../../eventbus/message-event-bus/message-event-bus';
|
import { MessageEventBus } from '../../eventbus/message-event-bus/message-event-bus';
|
||||||
import { PrometheusMetricsService } from '../prometheus-metrics.service';
|
import { PrometheusMetricsService } from '../prometheus-metrics.service';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||||
|
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
export interface SecretsProviderSettings<T = IDataObject> {
|
export interface SecretsProviderSettings<T = IDataObject> {
|
||||||
connected: boolean;
|
connected: boolean;
|
||||||
connectedAt: Date | null;
|
connectedAt: Date | null;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import type { WorkflowEntity } from '@n8n/db';
|
import type { WorkflowEntity } from '@n8n/db';
|
||||||
import type { IWorkflowDb } from '@n8n/db';
|
import type { IWorkflowDb } from '@n8n/db';
|
||||||
@@ -18,10 +22,6 @@ import {
|
|||||||
import type { TypeUnit } from '@/modules/insights/database/entities/insights-shared';
|
import type { TypeUnit } from '@/modules/insights/database/entities/insights-shared';
|
||||||
import { InsightsMetadataRepository } from '@/modules/insights/database/repositories/insights-metadata.repository';
|
import { InsightsMetadataRepository } from '@/modules/insights/database/repositories/insights-metadata.repository';
|
||||||
import { InsightsRawRepository } from '@/modules/insights/database/repositories/insights-raw.repository';
|
import { InsightsRawRepository } from '@/modules/insights/database/repositories/insights-raw.repository';
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import { InsightsCollectionService } from '../insights-collection.service';
|
import { InsightsCollectionService } from '../insights-collection.service';
|
||||||
import { InsightsConfig } from '../insights.config';
|
import { InsightsConfig } from '../insights.config';
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import { InsightsRawRepository } from '@/modules/insights/database/repositories/insights-raw.repository';
|
import { InsightsRawRepository } from '@/modules/insights/database/repositories/insights-raw.repository';
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createMetadata,
|
createMetadata,
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import type { LicenseState } from '@n8n/backend-common';
|
import type { LicenseState } from '@n8n/backend-common';
|
||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createCompactedInsightsEvent,
|
createCompactedInsightsEvent,
|
||||||
createMetadata,
|
createMetadata,
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import { LicenseState } from '@n8n/backend-common';
|
import { LicenseState } from '@n8n/backend-common';
|
||||||
|
import { mockInstance, testDb } from '@n8n/backend-test-utils';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { LicenseMocker } from '@test-integration/license';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
|
|
||||||
import { TypeToNumber } from '../database/entities/insights-shared';
|
import { TypeToNumber } from '../database/entities/insights-shared';
|
||||||
import { InsightsByPeriodRepository } from '../database/repositories/insights-by-period.repository';
|
import { InsightsByPeriodRepository } from '../database/repositories/insights-by-period.repository';
|
||||||
import { InsightsController } from '../insights.controller';
|
import { InsightsController } from '../insights.controller';
|
||||||
|
|
||||||
// Initialize DB once for all tests
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await testDb.init();
|
await testDb.init();
|
||||||
new LicenseMocker().mockLicenseState(Container.get(LicenseState));
|
Container.set(
|
||||||
|
LicenseState,
|
||||||
|
mock<LicenseState>({
|
||||||
|
getInsightsMaxHistory: jest.fn().mockReturnValue(-1),
|
||||||
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Terminate DB once after all tests complete
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await testDb.terminate();
|
await testDb.terminate();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import type { InsightsDateRange } from '@n8n/api-types';
|
import type { InsightsDateRange } from '@n8n/api-types';
|
||||||
import type { LicenseState } from '@n8n/backend-common';
|
import type { LicenseState } from '@n8n/backend-common';
|
||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import type { Project } from '@n8n/db';
|
import type { Project } from '@n8n/db';
|
||||||
import type { WorkflowEntity } from '@n8n/db';
|
import type { WorkflowEntity } from '@n8n/db';
|
||||||
import type { IWorkflowDb } from '@n8n/db';
|
import type { IWorkflowDb } from '@n8n/db';
|
||||||
@@ -12,11 +16,6 @@ import { DateTime } from 'luxon';
|
|||||||
import type { InstanceSettings } from 'n8n-core';
|
import type { InstanceSettings } from 'n8n-core';
|
||||||
import type { IRun } from 'n8n-workflow';
|
import type { IRun } from 'n8n-workflow';
|
||||||
|
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createCompactedInsightsEvent,
|
createCompactedInsightsEvent,
|
||||||
createMetadata,
|
createMetadata,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as testDb from '@test-integration/test-db';
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
|
||||||
import { InsightsByPeriod } from '../insights-by-period';
|
import { InsightsByPeriod } from '../insights-by-period';
|
||||||
import type { PeriodUnit, TypeUnit } from '../insights-shared';
|
import type { PeriodUnit, TypeUnit } from '../insights-shared';
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import { createMetadata, createRawInsightsEvent } from './db-utils';
|
import { createMetadata, createRawInsightsEvent } from './db-utils';
|
||||||
import { InsightsRawRepository } from '../../repositories/insights-raw.repository';
|
import { InsightsRawRepository } from '../../repositories/insights-raw.repository';
|
||||||
import { InsightsRaw } from '../insights-raw';
|
import { InsightsRaw } from '../insights-raw';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
import { createTeamProject } from '@n8n/backend-test-utils';
|
||||||
|
import { createWorkflow } from '@n8n/backend-test-utils';
|
||||||
|
import { testDb } from '@n8n/backend-test-utils';
|
||||||
|
import { testModules } from '@n8n/backend-test-utils';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
import { InsightsConfig } from '@/modules/insights/insights.config';
|
import { InsightsConfig } from '@/modules/insights/insights.config';
|
||||||
import { createTeamProject } from '@test-integration/db/projects';
|
|
||||||
import { createWorkflow } from '@test-integration/db/workflows';
|
|
||||||
import * as testDb from '@test-integration/test-db';
|
|
||||||
import * as testModules from '@test-integration/test-modules';
|
|
||||||
|
|
||||||
import { createCompactedInsightsEvent, createMetadata } from '../../entities/__tests__/db-utils';
|
import { createCompactedInsightsEvent, createMetadata } from '../../entities/__tests__/db-utils';
|
||||||
import { InsightsByPeriodRepository } from '../insights-by-period.repository';
|
import { InsightsByPeriodRepository } from '../insights-by-period.repository';
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
|
import { sql } from '@n8n/db';
|
||||||
import { Container, Service } from '@n8n/di';
|
import { Container, Service } from '@n8n/di';
|
||||||
import type { SelectQueryBuilder } from '@n8n/typeorm';
|
import type { SelectQueryBuilder } from '@n8n/typeorm';
|
||||||
import { DataSource, LessThanOrEqual, Repository } from '@n8n/typeorm';
|
import { DataSource, LessThanOrEqual, Repository } from '@n8n/typeorm';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { sql } from '@/utils/sql';
|
|
||||||
|
|
||||||
import { InsightsByPeriod } from '../entities/insights-by-period';
|
import { InsightsByPeriod } from '../entities/insights-by-period';
|
||||||
import type { PeriodUnit } from '../entities/insights-shared';
|
import type { PeriodUnit } from '../entities/insights-shared';
|
||||||
import { PeriodUnitToNumber, TypeToNumber } from '../entities/insights-shared';
|
import { PeriodUnitToNumber, TypeToNumber } from '../entities/insights-shared';
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { InsightsDateFilterDto, ListInsightsWorkflowQueryDto } from '@n8n/api-types';
|
import { InsightsDateFilterDto, ListInsightsWorkflowQueryDto } from '@n8n/api-types';
|
||||||
import type { InsightsSummary, InsightsByTime, InsightsByWorkflow } from '@n8n/api-types';
|
import type { InsightsSummary, InsightsByTime, InsightsByWorkflow } from '@n8n/api-types';
|
||||||
|
import { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Get, GlobalScope, Licensed, Query, RestController } from '@n8n/decorators';
|
import { Get, GlobalScope, Licensed, Query, RestController } from '@n8n/decorators';
|
||||||
import type { UserError } from 'n8n-workflow';
|
import type { UserError } from 'n8n-workflow';
|
||||||
|
|
||||||
import { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { InsightsService } from './insights.service';
|
import { InsightsService } from './insights.service';
|
||||||
|
|
||||||
export class ForbiddenError extends Error {
|
export class ForbiddenError extends Error {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { GlobalConfig } from '@n8n/config';
|
import type { GlobalConfig } from '@n8n/config';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import { InstanceSettings } from 'n8n-core';
|
import { InstanceSettings } from 'n8n-core';
|
||||||
import { PostHog } from 'posthog-node';
|
import { PostHog } from 'posthog-node';
|
||||||
|
|
||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
jest.mock('posthog-node');
|
jest.mock('posthog-node');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { TagEntity, WorkflowEntity } from '@n8n/db';
|
import type { AuthenticatedRequest, TagEntity, WorkflowEntity } from '@n8n/db';
|
||||||
import type { ExecutionStatus, ICredentialDataDecryptedObject } from 'n8n-workflow';
|
import type { ExecutionStatus, ICredentialDataDecryptedObject } from 'n8n-workflow';
|
||||||
|
|
||||||
import type { AuthlessRequest, AuthenticatedRequest } from '@/requests';
|
import type { AuthlessRequest } from '@/requests';
|
||||||
import type { Risk } from '@/security-audit/types';
|
import type { Risk } from '@/security-audit/types';
|
||||||
|
|
||||||
export type PaginatedRequest = AuthenticatedRequest<
|
export type PaginatedRequest = AuthenticatedRequest<
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { NextFunction } from 'express';
|
import type { NextFunction } from 'express';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import * as middlewares from '../shared/middlewares/global.middleware';
|
import * as middlewares from '../shared/middlewares/global.middleware';
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
DeleteProjectDto,
|
DeleteProjectDto,
|
||||||
UpdateProjectDto,
|
UpdateProjectDto,
|
||||||
} from '@n8n/api-types';
|
} from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { ProjectRepository } from '@n8n/db';
|
import { ProjectRepository } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
@@ -12,7 +13,6 @@ import type { Response } from 'express';
|
|||||||
import { ProjectController } from '@/controllers/project.controller';
|
import { ProjectController } from '@/controllers/project.controller';
|
||||||
import { ResponseError } from '@/errors/response-errors/abstract/response.error';
|
import { ResponseError } from '@/errors/response-errors/abstract/response.error';
|
||||||
import type { PaginatedRequest } from '@/public-api/types';
|
import type { PaginatedRequest } from '@/public-api/types';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { ProjectService } from '@/services/project.service.ee';
|
import { ProjectService } from '@/services/project.service.ee';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { PullWorkFolderRequestDto } from '@n8n/api-types';
|
import { PullWorkFolderRequestDto } from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import type { StatusResult } from 'simple-git';
|
import type { StatusResult } from 'simple-git';
|
||||||
@@ -11,7 +12,6 @@ import { SourceControlPreferencesService } from '@/environments.ee/source-contro
|
|||||||
import { SourceControlService } from '@/environments.ee/source-control/source-control.service.ee';
|
import { SourceControlService } from '@/environments.ee/source-control/source-control.service.ee';
|
||||||
import type { ImportResult } from '@/environments.ee/source-control/types/import-result';
|
import type { ImportResult } from '@/environments.ee/source-control/types/import-result';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
import { apiKeyHasScopeWithGlobalScopeFallback } from '../../shared/middlewares/global.middleware';
|
import { apiKeyHasScopeWithGlobalScopeFallback } from '../../shared/middlewares/global.middleware';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { InviteUsersRequestDto, RoleChangeRequestDto } from '@n8n/api-types';
|
import { InviteUsersRequestDto, RoleChangeRequestDto } from '@n8n/api-types';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { ProjectRelationRepository } from '@n8n/db';
|
import { ProjectRelationRepository } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
@@ -7,7 +8,7 @@ import type { Response } from 'express';
|
|||||||
import { InvitationController } from '@/controllers/invitation.controller';
|
import { InvitationController } from '@/controllers/invitation.controller';
|
||||||
import { UsersController } from '@/controllers/users.controller';
|
import { UsersController } from '@/controllers/users.controller';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import type { AuthenticatedRequest, UserRequest } from '@/requests';
|
import type { UserRequest } from '@/requests';
|
||||||
|
|
||||||
import { clean, getAllUsersAndCount, getUser } from './users.service.ee';
|
import { clean, getAllUsersAndCount, getUser } from './users.service.ee';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-invalid-void-type */
|
/* eslint-disable @typescript-eslint/no-invalid-void-type */
|
||||||
import type { BooleanLicenseFeature } from '@n8n/constants';
|
import type { BooleanLicenseFeature } from '@n8n/constants';
|
||||||
|
import type { AuthenticatedRequest } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import type { ApiKeyScope, Scope } from '@n8n/permissions';
|
import type { ApiKeyScope, Scope } from '@n8n/permissions';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
@@ -9,7 +10,6 @@ import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error';
|
|||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { License } from '@/license';
|
import { License } from '@/license';
|
||||||
import { userHasScopes } from '@/permissions.ee/check-access';
|
import { userHasScopes } from '@/permissions.ee/check-access';
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
||||||
|
|
||||||
import type { PaginatedRequest } from '../../../types';
|
import type { PaginatedRequest } from '../../../types';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Logger } from '@n8n/backend-common';
|
import type { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import type { Application } from 'express';
|
import type { Application } from 'express';
|
||||||
import { captor, mock } from 'jest-mock-extended';
|
import { captor, mock } from 'jest-mock-extended';
|
||||||
@@ -11,7 +12,6 @@ import { Push } from '@/push';
|
|||||||
import { SSEPush } from '@/push/sse.push';
|
import { SSEPush } from '@/push/sse.push';
|
||||||
import type { WebSocketPushRequest, SSEPushRequest, PushResponse } from '@/push/types';
|
import type { WebSocketPushRequest, SSEPushRequest, PushResponse } from '@/push/types';
|
||||||
import { WebSocketPush } from '@/push/websocket.push';
|
import { WebSocketPush } from '@/push/websocket.push';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import type { PushConfig } from '../push.config';
|
import type { PushConfig } from '../push.config';
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { createHeartbeatMessage, type PushMessage } from '@n8n/api-types';
|
import { createHeartbeatMessage, type PushMessage } from '@n8n/api-types';
|
||||||
import { Logger } from '@n8n/backend-common';
|
import { Logger } from '@n8n/backend-common';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { User } from '@n8n/db';
|
import type { User } from '@n8n/db';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import type WebSocket from 'ws';
|
import type WebSocket from 'ws';
|
||||||
|
|
||||||
import { WebSocketPush } from '@/push/websocket.push';
|
import { WebSocketPush } from '@/push/websocket.push';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import type { User } from '@n8n/db';
|
import type { AuthenticatedRequest, User } from '@n8n/db';
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
import type { WebSocket } from 'ws';
|
import type { WebSocket } from 'ws';
|
||||||
|
|
||||||
import type { AuthenticatedRequest } from '@/requests';
|
|
||||||
|
|
||||||
// TODO: move all push related types here
|
// TODO: move all push related types here
|
||||||
|
|
||||||
export type PushRequest = AuthenticatedRequest<{}, {}, {}, { pushRef: string }>;
|
export type PushRequest = AuthenticatedRequest<{}, {}, {}, { pushRef: string }>;
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
import type { ProjectIcon, ProjectType } from '@n8n/api-types';
|
import type { ProjectIcon, ProjectType } from '@n8n/api-types';
|
||||||
import type { Variables, Project, User, ListQueryDb, WorkflowHistory } from '@n8n/db';
|
import type {
|
||||||
|
APIRequest,
|
||||||
|
AuthenticatedRequest,
|
||||||
|
Variables,
|
||||||
|
Project,
|
||||||
|
User,
|
||||||
|
ListQueryDb,
|
||||||
|
WorkflowHistory,
|
||||||
|
} from '@n8n/db';
|
||||||
import type { AssignableGlobalRole, GlobalRole, ProjectRole, Scope } from '@n8n/permissions';
|
import type { AssignableGlobalRole, GlobalRole, ProjectRole, Scope } from '@n8n/permissions';
|
||||||
import type express from 'express';
|
|
||||||
import type {
|
import type {
|
||||||
ICredentialDataDecryptedObject,
|
ICredentialDataDecryptedObject,
|
||||||
INodeCredentialTestRequest,
|
INodeCredentialTestRequest,
|
||||||
IPersonalizationSurveyAnswersV4,
|
IPersonalizationSurveyAnswersV4,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export type APIRequest<
|
|
||||||
RouteParams = {},
|
|
||||||
ResponseBody = {},
|
|
||||||
RequestBody = {},
|
|
||||||
RequestQuery = {},
|
|
||||||
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery> & {
|
|
||||||
browserId?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type AuthlessRequest<
|
export type AuthlessRequest<
|
||||||
RouteParams = {},
|
RouteParams = {},
|
||||||
ResponseBody = {},
|
ResponseBody = {},
|
||||||
@@ -24,19 +22,6 @@ export type AuthlessRequest<
|
|||||||
RequestQuery = {},
|
RequestQuery = {},
|
||||||
> = APIRequest<RouteParams, ResponseBody, RequestBody, RequestQuery>;
|
> = APIRequest<RouteParams, ResponseBody, RequestBody, RequestQuery>;
|
||||||
|
|
||||||
export type AuthenticatedRequest<
|
|
||||||
RouteParams = {},
|
|
||||||
ResponseBody = {},
|
|
||||||
RequestBody = {},
|
|
||||||
RequestQuery = {},
|
|
||||||
> = Omit<APIRequest<RouteParams, ResponseBody, RequestBody, RequestQuery>, 'user' | 'cookies'> & {
|
|
||||||
user: User;
|
|
||||||
cookies: Record<string, string | undefined>;
|
|
||||||
headers: express.Request['headers'] & {
|
|
||||||
'push-ref': string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export namespace ListQuery {
|
export namespace ListQuery {
|
||||||
export type Request = AuthenticatedRequest<{}, {}, {}, Params> & {
|
export type Request = AuthenticatedRequest<{}, {}, {}, Params> & {
|
||||||
listQueryOptions?: Options;
|
listQueryOptions?: Options;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mockLogger } from '@n8n/backend-test-utils';
|
import { mockLogger } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import * as BullModule from 'bull';
|
import * as BullModule from 'bull';
|
||||||
@@ -7,7 +8,6 @@ import { InstanceSettings } from 'n8n-core';
|
|||||||
import { ApplicationError, ExecutionCancelledError } from 'n8n-workflow';
|
import { ApplicationError, ExecutionCancelledError } from 'n8n-workflow';
|
||||||
|
|
||||||
import type { ActiveExecutions } from '@/active-executions';
|
import type { ActiveExecutions } from '@/active-executions';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
|
|
||||||
import { JOB_TYPE_NAME, QUEUE_NAME } from '../constants';
|
import { JOB_TYPE_NAME, QUEUE_NAME } from '../constants';
|
||||||
import type { JobProcessor } from '../job-processor';
|
import type { JobProcessor } from '../job-processor';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { inDevelopment, inProduction, LicenseState } from '@n8n/backend-common';
|
import { inDevelopment, inProduction, LicenseState } from '@n8n/backend-common';
|
||||||
import { SecurityConfig } from '@n8n/config';
|
import { SecurityConfig } from '@n8n/config';
|
||||||
import { Time } from '@n8n/constants';
|
import { Time } from '@n8n/constants';
|
||||||
|
import type { APIRequest } from '@n8n/db';
|
||||||
import { Container, Service } from '@n8n/di';
|
import { Container, Service } from '@n8n/di';
|
||||||
import cookieParser from 'cookie-parser';
|
import cookieParser from 'cookie-parser';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
@@ -26,7 +27,6 @@ import { handleMfaDisable, isMfaFeatureEnabled } from '@/mfa/helpers';
|
|||||||
import { PostHogClient } from '@/posthog';
|
import { PostHogClient } from '@/posthog';
|
||||||
import { isApiEnabled, loadPublicApiVersions } from '@/public-api';
|
import { isApiEnabled, loadPublicApiVersions } from '@/public-api';
|
||||||
import { Push } from '@/push';
|
import { Push } from '@/push';
|
||||||
import type { APIRequest } from '@/requests';
|
|
||||||
import * as ResponseHelper from '@/response-helper';
|
import * as ResponseHelper from '@/response-helper';
|
||||||
import type { FrontendService } from '@/services/frontend.service';
|
import type { FrontendService } from '@/services/frontend.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { Logger } from '@n8n/backend-common';
|
import type { Logger } from '@n8n/backend-common';
|
||||||
|
import { randomName } from '@n8n/backend-test-utils';
|
||||||
|
import { mockInstance } from '@n8n/backend-test-utils';
|
||||||
import type { GlobalConfig } from '@n8n/config';
|
import type { GlobalConfig } from '@n8n/config';
|
||||||
import { LICENSE_FEATURES } from '@n8n/constants';
|
import { LICENSE_FEATURES } from '@n8n/constants';
|
||||||
import { InstalledNodes } from '@n8n/db';
|
import { InstalledNodes } from '@n8n/db';
|
||||||
@@ -26,9 +28,7 @@ import type { License } from '@/license';
|
|||||||
import type { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
import type { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
||||||
import type { Publisher } from '@/scaling/pubsub/publisher.service';
|
import type { Publisher } from '@/scaling/pubsub/publisher.service';
|
||||||
import { CommunityPackagesService } from '@/services/community-packages.service';
|
import { CommunityPackagesService } from '@/services/community-packages.service';
|
||||||
import { mockInstance } from '@test/mocking';
|
|
||||||
import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '@test-integration/constants';
|
import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '@test-integration/constants';
|
||||||
import { randomName } from '@test-integration/random';
|
|
||||||
import { mockPackageName, mockPackagePair } from '@test-integration/utils';
|
import { mockPackageName, mockPackagePair } from '@test-integration/utils';
|
||||||
|
|
||||||
jest.mock('fs/promises');
|
jest.mock('fs/promises');
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user