mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
refactor(core): Move DbConnection to @n8n/db (#16616)
This commit is contained in:
@@ -101,3 +101,5 @@ export const LDAP_DEFAULT_CONFIGURATION: LdapConfig = {
|
||||
searchPageSize: 0,
|
||||
searchTimeout: 60,
|
||||
};
|
||||
|
||||
export { Time } from './time';
|
||||
|
||||
23
packages/@n8n/constants/src/time.ts
Normal file
23
packages/@n8n/constants/src/time.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Convert time from any time unit to any other unit
|
||||
*/
|
||||
export const Time = {
|
||||
milliseconds: {
|
||||
toMinutes: 1 / (60 * 1000),
|
||||
toSeconds: 1 / 1000,
|
||||
},
|
||||
seconds: {
|
||||
toMilliseconds: 1000,
|
||||
},
|
||||
minutes: {
|
||||
toMilliseconds: 60 * 1000,
|
||||
},
|
||||
hours: {
|
||||
toMilliseconds: 60 * 60 * 1000,
|
||||
toSeconds: 60 * 60,
|
||||
},
|
||||
days: {
|
||||
toSeconds: 24 * 60 * 60,
|
||||
toMilliseconds: 24 * 60 * 60 * 1000,
|
||||
},
|
||||
};
|
||||
@@ -25,6 +25,7 @@
|
||||
"@n8n/backend-common": "workspace:^",
|
||||
"@n8n/config": "workspace:^",
|
||||
"@n8n/constants": "workspace:^",
|
||||
"@n8n/decorators": "workspace:^",
|
||||
"@n8n/di": "workspace:^",
|
||||
"@n8n/permissions": "workspace:^",
|
||||
"@n8n/typeorm": "catalog:",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { ModuleRegistry } from '@n8n/backend-common';
|
||||
import type { GlobalConfig, InstanceSettingsConfig } from '@n8n/config';
|
||||
import { mysqlMigrations } from '@n8n/db';
|
||||
import { postgresMigrations } from '@n8n/db';
|
||||
import { sqliteMigrations } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import path from 'path';
|
||||
|
||||
import { mysqlMigrations } from '../../migrations/mysqldb';
|
||||
import { postgresMigrations } from '../../migrations/postgresdb';
|
||||
import { sqliteMigrations } from '../../migrations/sqlite';
|
||||
import { DbConnectionOptions } from '../db-connection-options';
|
||||
|
||||
describe('DbConnectionOptions', () => {
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DatabaseConfig } from '@n8n/config';
|
||||
import type { Migration } from '@n8n/db';
|
||||
import * as migrationHelper from '@n8n/db';
|
||||
import { DataSource, type DataSourceOptions } from '@n8n/typeorm';
|
||||
import { mock, mockDeep } from 'jest-mock-extended';
|
||||
import type { ErrorReporter } from 'n8n-core';
|
||||
import { DbConnectionTimeoutError } from 'n8n-workflow';
|
||||
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import type { DbConnectionOptions } from '@/databases/db-connection-options';
|
||||
import * as migrationHelper from '../../migrations/migration-helpers';
|
||||
import type { Migration } from '../../migrations/migration-types';
|
||||
import { DbConnection } from '../db-connection';
|
||||
import type { DbConnectionOptions } from '../db-connection-options';
|
||||
|
||||
jest.mock('@n8n/typeorm', () => ({
|
||||
DataSource: jest.fn(),
|
||||
@@ -159,6 +159,7 @@ describe('DbConnection', () => {
|
||||
// @ts-expect-error readonly property
|
||||
dataSource.isInitialized = true;
|
||||
dataSource.query.mockResolvedValue([{ '1': 1 }]);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const scheduleNextPingSpy = jest.spyOn(dbConnection as any, 'scheduleNextPing');
|
||||
|
||||
// @ts-expect-error private property
|
||||
@@ -189,6 +190,7 @@ describe('DbConnection', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const pingSpy = jest.spyOn(dbConnection as any, 'ping');
|
||||
|
||||
// @ts-expect-error private property
|
||||
@@ -1,12 +1,5 @@
|
||||
import { ModuleRegistry } from '@n8n/backend-common';
|
||||
import { DatabaseConfig, InstanceSettingsConfig } from '@n8n/config';
|
||||
import {
|
||||
entities,
|
||||
subscribers,
|
||||
mysqlMigrations,
|
||||
postgresMigrations,
|
||||
sqliteMigrations,
|
||||
} from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { DataSourceOptions, LoggerOptions } from '@n8n/typeorm';
|
||||
import type { MysqlConnectionOptions } from '@n8n/typeorm/driver/mysql/MysqlConnectionOptions';
|
||||
@@ -14,8 +7,14 @@ import type { PostgresConnectionOptions } from '@n8n/typeorm/driver/postgres/Pos
|
||||
import type { SqliteConnectionOptions } from '@n8n/typeorm/driver/sqlite/SqliteConnectionOptions';
|
||||
import type { SqlitePooledConnectionOptions } from '@n8n/typeorm/driver/sqlite-pooled/SqlitePooledConnectionOptions';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
import type { TlsOptions } from 'node:tls';
|
||||
import path from 'path';
|
||||
import type { TlsOptions } from 'tls';
|
||||
|
||||
import { entities } from '../entities';
|
||||
import { mysqlMigrations } from '../migrations/mysqldb';
|
||||
import { postgresMigrations } from '../migrations/postgresdb';
|
||||
import { sqliteMigrations } from '../migrations/sqlite';
|
||||
import { subscribers } from '../subscribers';
|
||||
|
||||
@Service()
|
||||
export class DbConnectionOptions {
|
||||
@@ -1,16 +1,15 @@
|
||||
import { inTest } from '@n8n/backend-common';
|
||||
import { DatabaseConfig } from '@n8n/config';
|
||||
import type { Migration } from '@n8n/db';
|
||||
import { wrapMigration } from '@n8n/db';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Memoized } from '@n8n/decorators';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
import { DataSource } from '@n8n/typeorm';
|
||||
import { ErrorReporter } from 'n8n-core';
|
||||
import { DbConnectionTimeoutError, ensureError } from 'n8n-workflow';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
|
||||
import { DbConnectionOptions } from './db-connection-options';
|
||||
import { wrapMigration } from '../migrations/migration-helpers';
|
||||
import type { Migration } from '../migrations/migration-types';
|
||||
|
||||
type ConnectionState = {
|
||||
connected: boolean;
|
||||
@@ -28,3 +28,5 @@ export { postgresMigrations } from './migrations/postgresdb';
|
||||
|
||||
export { wrapMigration } from './migrations/migration-helpers';
|
||||
export * from './migrations/migration-types';
|
||||
export { DbConnection } from './connection/db-connection';
|
||||
export { DbConnectionOptions } from './connection/db-connection-options';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { inTest, inDevelopment, Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { OnShutdown } from '@n8n/decorators';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
import compression from 'compression';
|
||||
@@ -11,7 +12,6 @@ import isbot from 'isbot';
|
||||
|
||||
import config from '@/config';
|
||||
import { N8N_VERSION, TEMPLATES_DIR } from '@/constants';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error';
|
||||
import { ExternalHooks } from '@/external-hooks';
|
||||
import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { InvalidAuthTokenRepository } from '@n8n/db';
|
||||
import type { UserRepository } from '@n8n/db';
|
||||
@@ -8,7 +9,7 @@ import jwt from 'jsonwebtoken';
|
||||
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import { AUTH_COOKIE_NAME, Time } from '@/constants';
|
||||
import { AUTH_COOKIE_NAME } from '@/constants';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
import { JwtService } from '@/services/jwt.service';
|
||||
import type { UrlService } from '@/services/url.service';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { User } from '@n8n/db';
|
||||
import { InvalidAuthTokenRepository, UserRepository } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
@@ -9,7 +10,7 @@ import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken';
|
||||
import type { StringValue as TimeUnitValue } from 'ms';
|
||||
|
||||
import config from '@/config';
|
||||
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
|
||||
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||
import { License } from '@/license';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Iso8601DateTimeString } from '@n8n/api-types';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { Workflow } from 'n8n-workflow';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
|
||||
type WorkflowCacheHash = Record<User['id'], Iso8601DateTimeString>;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { User, WorkflowEntity } from '@n8n/db';
|
||||
import { WorkflowRepository } from '@n8n/db';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { SelectQueryBuilder } from '@n8n/typeorm';
|
||||
import type { Config } from '@oclif/core';
|
||||
@@ -8,7 +9,6 @@ import { mock } from 'jest-mock-extended';
|
||||
import type { IRun } from 'n8n-workflow';
|
||||
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { DeprecationService } from '@/deprecation/deprecation.service';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { User, WorkflowEntity } from '@n8n/db';
|
||||
import { WorkflowRepository } from '@n8n/db';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { Config } from '@oclif/core';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IRun } from 'n8n-workflow';
|
||||
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { DeprecationService } from '@/deprecation/deprecation.service';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay';
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { LICENSE_FEATURES } from '@n8n/constants';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { Command, Errors } from '@oclif/core';
|
||||
import {
|
||||
@@ -25,7 +26,6 @@ import type { AbstractServer } from '@/abstract-server';
|
||||
import config from '@/config';
|
||||
import { N8N_VERSION, N8N_RELEASE_DATE } from '@/constants';
|
||||
import * as CrashJournal from '@/crash-journal';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { getDataDeduplicationService } from '@/deduplication';
|
||||
import { DeprecationService } from '@/deprecation/deprecation.service';
|
||||
import { TestRunCleanupService } from '@/evaluation.ee/test-runner/test-run-cleanup.service.ee';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import type { Migration } from '@n8n/db';
|
||||
import { wrapMigration } from '@n8n/db';
|
||||
import { wrapMigration, DbConnectionOptions } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import type { DataSourceOptions as ConnectionOptions } from '@n8n/typeorm';
|
||||
@@ -8,8 +8,6 @@ import type { DataSourceOptions as ConnectionOptions } from '@n8n/typeorm';
|
||||
import { MigrationExecutor, DataSource as Connection } from '@n8n/typeorm';
|
||||
import { Command, Flags } from '@oclif/core';
|
||||
|
||||
import { DbConnectionOptions } from '@/databases/db-connection-options';
|
||||
|
||||
// This function is extracted to make it easier to unit test it.
|
||||
// Mocking turned into a mess due to this command using typeorm and the db
|
||||
// config directly and customizing and monkey patching parts.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Time } from '@n8n/constants';
|
||||
import { readFileSync, statSync } from 'fs';
|
||||
import type { n8n } from 'n8n-core';
|
||||
import type { ITaskDataConnections } from 'n8n-workflow';
|
||||
@@ -74,30 +75,6 @@ export const CREDENTIAL_BLANKING_VALUE = '__n8n_BLANK_VALUE_e5362baf-c777-4d57-a
|
||||
export const UM_FIX_INSTRUCTION =
|
||||
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
||||
|
||||
/**
|
||||
* Convert time from any time unit to any other unit
|
||||
*/
|
||||
export const Time = {
|
||||
milliseconds: {
|
||||
toMinutes: 1 / (60 * 1000),
|
||||
toSeconds: 1 / 1000,
|
||||
},
|
||||
seconds: {
|
||||
toMilliseconds: 1000,
|
||||
},
|
||||
minutes: {
|
||||
toMilliseconds: 60 * 1000,
|
||||
},
|
||||
hours: {
|
||||
toMilliseconds: 60 * 60 * 1000,
|
||||
toSeconds: 60 * 60,
|
||||
},
|
||||
days: {
|
||||
toSeconds: 24 * 60 * 60,
|
||||
toMilliseconds: 24 * 60 * 60 * 1000,
|
||||
},
|
||||
};
|
||||
|
||||
export const MIN_PASSWORD_CHAR_LENGTH = 8;
|
||||
|
||||
export const MAX_PASSWORD_CHAR_LENGTH = 64;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import { CredentialsRepository } from '@n8n/db';
|
||||
@@ -10,7 +11,6 @@ import { Cipher, type InstanceSettings, ExternalSecretsProxy } from 'n8n-core';
|
||||
import type { IWorkflowExecuteAdditionalData } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { OAuth1CredentialController } from '@/controllers/oauth/oauth1-credential.controller';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import { CredentialsRepository } from '@n8n/db';
|
||||
@@ -10,7 +11,7 @@ import { Cipher, type InstanceSettings, ExternalSecretsProxy } from 'n8n-core';
|
||||
import type { IWorkflowExecuteAdditionalData } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { CREDENTIAL_BLANKING_VALUE, Time } from '@/constants';
|
||||
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
|
||||
import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { CredentialsEntity, ICredentialsDb } from '@n8n/db';
|
||||
import { CredentialsRepository } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
@@ -9,7 +10,7 @@ import { Credentials } from 'n8n-core';
|
||||
import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
|
||||
import { jsonParse, UnexpectedError } from 'n8n-workflow';
|
||||
|
||||
import { RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
|
||||
@@ -4,6 +4,7 @@ import { GlobalConfig } from '@n8n/config';
|
||||
import {
|
||||
LICENSE_FEATURES,
|
||||
LICENSE_QUOTAS,
|
||||
Time,
|
||||
UNLIMITED_LICENSE_QUOTA,
|
||||
type BooleanLicenseFeature,
|
||||
type NumericLicenseFeature,
|
||||
@@ -18,7 +19,7 @@ import { InstanceSettings } from 'n8n-core';
|
||||
import config from '@/config';
|
||||
import { LicenseMetricsService } from '@/metrics/license-metrics.service';
|
||||
|
||||
import { N8N_VERSION, SETTINGS_LICENSE_CERT_KEY, Time } from './constants';
|
||||
import { N8N_VERSION, SETTINGS_LICENSE_CERT_KEY } from './constants';
|
||||
|
||||
const LICENSE_RENEWAL_DISABLED_WARNING =
|
||||
'Automatic license renewal is disabled. The license will not renew automatically, and access to licensed features may be lost!';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { WorkflowRepository } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type express from 'express';
|
||||
@@ -10,7 +11,7 @@ import promClient, { type Counter, type Gauge } from 'prom-client';
|
||||
import semverParse from 'semver/functions/parse';
|
||||
|
||||
import config from '@/config';
|
||||
import { N8N_VERSION, Time } from '@/constants';
|
||||
import { N8N_VERSION } from '@/constants';
|
||||
import type { EventMessageTypes } from '@/eventbus';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
import { EventService } from '@/events/event.service';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { LicenseState } from '@n8n/backend-common';
|
||||
import { mockLogger } from '@n8n/backend-test-utils';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { createTeamProject } from '@test-integration/db/projects';
|
||||
import { createWorkflow } from '@test-integration/db/workflows';
|
||||
import * as testDb from '@test-integration/test-db';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { LicenseState, Logger } from '@n8n/backend-common';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Service } from '@n8n/di';
|
||||
import { strict } from 'assert';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
|
||||
import { InsightsByPeriodRepository } from './database/repositories/insights-by-period.repository';
|
||||
import { InsightsConfig } from './insights.config';
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { mockLogger } from '@n8n/backend-test-utils';
|
||||
import type { GlobalConfig } from '@n8n/config';
|
||||
import type { DbConnection } from '@n8n/db';
|
||||
import type express from 'express';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { InstanceSettings } from 'n8n-core';
|
||||
import { AssertionError } from 'node:assert';
|
||||
import * as http from 'node:http';
|
||||
|
||||
import type { DbConnection } from '@/databases/db-connection';
|
||||
import type { ExternalHooks } from '@/external-hooks';
|
||||
import type { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service';
|
||||
import { bodyParser, rawBodyReader } from '@/middlewares';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { MultiMainMetadata } from '@n8n/decorators';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
|
||||
import config from '@/config';
|
||||
import { Time } from '@/constants';
|
||||
import { Publisher } from '@/scaling/pubsub/publisher.service';
|
||||
import { RedisClientService } from '@/services/redis-client.service';
|
||||
import { TypedEmitter } from '@/typed-emitter';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { isObjectLiteral, Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { ExecutionRepository } from '@n8n/db';
|
||||
import { OnLeaderStepdown, OnLeaderTakeover, OnShutdown } from '@n8n/decorators';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
@@ -17,7 +18,7 @@ import assert, { strict } from 'node:assert';
|
||||
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import config from '@/config';
|
||||
import { HIGHEST_SHUTDOWN_PRIORITY, Time } from '@/constants';
|
||||
import { HIGHEST_SHUTDOWN_PRIORITY } from '@/constants';
|
||||
import { EventService } from '@/events/event.service';
|
||||
import { assertNever } from '@/utils';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { Application } from 'express';
|
||||
import express from 'express';
|
||||
@@ -9,7 +10,6 @@ import http from 'node:http';
|
||||
import type { Server } from 'node:http';
|
||||
|
||||
import { CredentialsOverwrites } from '@/credentials-overwrites';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { CredentialsOverwritesAlreadySetError } from '@/errors/credentials-overwrites-already-set.error';
|
||||
import { NonJsonBodyError } from '@/errors/non-json-body.error';
|
||||
import { ExternalHooks } from '@/external-hooks';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { inDevelopment, inProduction, LicenseState } from '@n8n/backend-common';
|
||||
import { SecurityConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import express from 'express';
|
||||
@@ -12,7 +13,7 @@ import { resolve } from 'path';
|
||||
|
||||
import { AbstractServer } from '@/abstract-server';
|
||||
import config from '@/config';
|
||||
import { CLI_DIR, EDITOR_UI_DIST_DIR, inE2ETests, N8N_VERSION, Time } from '@/constants';
|
||||
import { CLI_DIR, EDITOR_UI_DIST_DIR, inE2ETests, N8N_VERSION } from '@/constants';
|
||||
import { ControllerRegistry } from '@/controller.registry';
|
||||
import { CredentialsOverwrites } from '@/credentials-overwrites';
|
||||
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Container, Service } from '@n8n/di';
|
||||
import { caching } from 'cache-manager';
|
||||
import { jsonStringify, UserError } from 'n8n-workflow';
|
||||
|
||||
import config from '@/config';
|
||||
import { Time } from '@/constants';
|
||||
import { MalformedRefreshValueError } from '@/errors/cache-errors/malformed-refresh-value.error';
|
||||
import { UncacheableValueError } from '@/errors/cache-errors/uncacheable-value.error';
|
||||
import type {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { mockLogger } from '@n8n/backend-test-utils';
|
||||
import type { ExecutionsConfig } from '@n8n/config';
|
||||
import type { DbConnection } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { InstanceSettings } from 'n8n-core';
|
||||
|
||||
import type { DbConnection } from '@/databases/db-connection';
|
||||
|
||||
import { ExecutionsPruningService } from '../executions-pruning.service';
|
||||
|
||||
describe('PruningService', () => {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { ExecutionsConfig } from '@n8n/config';
|
||||
import { ExecutionRepository } from '@n8n/db';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { ExecutionRepository, DbConnection } from '@n8n/db';
|
||||
import { OnLeaderStepdown, OnLeaderTakeover, OnShutdown } from '@n8n/decorators';
|
||||
import { Service } from '@n8n/di';
|
||||
import { BinaryDataService, InstanceSettings } from 'n8n-core';
|
||||
import { ensureError } from 'n8n-workflow';
|
||||
import { strict } from 'node:assert';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
|
||||
/**
|
||||
* Responsible for deleting old executions from the database and deleting their
|
||||
* associated binary data from the filesystem, on a rolling basis.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { TaskRunnersConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type WebSocket from 'ws';
|
||||
|
||||
import { Time, WsStatusCodes } from '@/constants';
|
||||
import { WsStatusCodes } from '@/constants';
|
||||
import { TaskBrokerWsServer } from '@/task-runners/task-broker/task-broker-ws-server';
|
||||
|
||||
describe('TaskBrokerWsServer', () => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { Logger } from '@n8n/backend-common';
|
||||
import type { TaskRunnersConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { RunnerMessage, TaskResultData } from '@n8n/task-runner';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { ApplicationError, type INodeTypeBaseDescription } from 'n8n-workflow';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import type { TaskRunnerLifecycleEvents } from '@/task-runners/task-runner-lifecycle-events';
|
||||
|
||||
import { TaskRejectError } from '../errors/task-reject.error';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Service } from '@n8n/di';
|
||||
import { randomBytes, timingSafeEqual } from 'crypto';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
|
||||
const GRANT_TOKEN_TTL = 15 * Time.seconds.toMilliseconds;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { TaskRunnersConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { BrokerMessage, RunnerMessage } from '@n8n/task-runner';
|
||||
import { jsonStringify, UserError } from 'n8n-workflow';
|
||||
import type WebSocket from 'ws';
|
||||
|
||||
import { Time, WsStatusCodes } from '@/constants';
|
||||
import { WsStatusCodes } from '@/constants';
|
||||
import { DefaultTaskRunnerDisconnectAnalyzer } from '@/task-runners/default-task-runner-disconnect-analyzer';
|
||||
import type {
|
||||
DisconnectAnalyzer,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { GlobalConfig, TaskRunnersConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import { Service } from '@n8n/di';
|
||||
import type {
|
||||
BrokerMessage,
|
||||
@@ -10,7 +11,6 @@ import type {
|
||||
import { UnexpectedError, UserError } from 'n8n-workflow';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { TaskDeferredError } from '@/task-runners/task-broker/errors/task-deferred.error';
|
||||
import { TaskRejectError } from '@/task-runners/task-broker/errors/task-reject.error';
|
||||
import { TaskRunnerAcceptTimeoutError } from '@/task-runners/task-broker/errors/task-runner-accept-timeout.error';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Time } from '@/constants';
|
||||
import { Time } from '@n8n/constants';
|
||||
|
||||
import { TaskRunnerRestartLoopError } from '@/task-runners/errors/task-runner-restart-loop-error';
|
||||
import type { TaskRunnerProcess } from '@/task-runners/task-runner-process';
|
||||
import { TypedEmitter } from '@/typed-emitter';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Time } from '@n8n/constants';
|
||||
import { WorkflowHistoryRepository } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
|
||||
import {
|
||||
getWorkflowHistoryPruneTime,
|
||||
isWorkflowHistoryEnabled,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { mockLogger } from '@n8n/backend-test-utils';
|
||||
import { ExecutionsConfig } from '@n8n/config';
|
||||
import { Time } from '@n8n/constants';
|
||||
import type { ExecutionEntity } from '@n8n/db';
|
||||
import { ExecutionRepository } from '@n8n/db';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { BinaryDataService, InstanceSettings } from 'n8n-core';
|
||||
import type { ExecutionStatus, IWorkflowBase } from 'n8n-workflow';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { ExecutionsPruningService } from '@/services/pruning/executions-pruning.service';
|
||||
|
||||
import {
|
||||
|
||||
@@ -15,6 +15,7 @@ export async function createWorkflowStatisticsItem(
|
||||
workflowId,
|
||||
});
|
||||
|
||||
// @ts-ignore CAT-957
|
||||
await Container.get(WorkflowStatisticsRepository).insert(entity);
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { entities } from '@n8n/db';
|
||||
import { DbConnection } from '@n8n/db';
|
||||
import { DbConnectionOptions } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { DataSourceOptions } from '@n8n/typeorm';
|
||||
import { DataSource as Connection } from '@n8n/typeorm';
|
||||
import { randomString } from 'n8n-workflow';
|
||||
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { DbConnectionOptions } from '@/databases/db-connection-options';
|
||||
|
||||
export const testDbPrefix = 'n8n_test_';
|
||||
|
||||
/**
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -554,6 +554,9 @@ importers:
|
||||
'@n8n/constants':
|
||||
specifier: workspace:^
|
||||
version: link:../constants
|
||||
'@n8n/decorators':
|
||||
specifier: workspace:^
|
||||
version: link:../decorators
|
||||
'@n8n/di':
|
||||
specifier: workspace:^
|
||||
version: link:../di
|
||||
|
||||
Reference in New Issue
Block a user