refactor(core): Replace typedi with our custom DI system (no-changelog) (#12389)

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-01-06 10:21:24 +01:00
committed by GitHub
parent 8053a4a176
commit 39d5e0ff87
413 changed files with 979 additions and 452 deletions

View File

@@ -1,3 +1,4 @@
import { Service } from '@n8n/di';
import type {
IGetExecutePollFunctions,
IGetExecuteTriggerFunctions,
@@ -16,7 +17,6 @@ import {
WorkflowActivationError,
WorkflowDeactivationError,
} from 'n8n-workflow';
import { Service } from 'typedi';
import { ErrorReporter } from './error-reporter';
import type { IWorkflowData } from './Interfaces';

View File

@@ -1,9 +1,9 @@
import { Container, Service } from '@n8n/di';
import { BINARY_ENCODING } from 'n8n-workflow';
import type { INodeExecutionData, IBinaryData } from 'n8n-workflow';
import { readFile, stat } from 'node:fs/promises';
import prettyBytes from 'pretty-bytes';
import type { Readable } from 'stream';
import Container, { Service } from 'typedi';
import type { BinaryData } from './types';
import { areConfigModes, binaryToBuffer } from './utils';

View File

@@ -1,6 +1,6 @@
import { Service } from '@n8n/di';
import fs from 'node:fs/promises';
import type { Readable } from 'node:stream';
import { Service } from 'typedi';
import { v4 as uuid } from 'uuid';
import type { BinaryData } from './types';

View File

@@ -1,5 +1,5 @@
import { Service } from '@n8n/di';
import { createHash, createCipheriv, createDecipheriv, randomBytes } from 'crypto';
import { Service } from 'typedi';
import { InstanceSettings } from './InstanceSettings';

View File

@@ -1,6 +1,6 @@
import { Container } from '@n8n/di';
import type { ICredentialDataDecryptedObject, ICredentialsEncrypted } from 'n8n-workflow';
import { ApplicationError, ICredentials, jsonParse } from 'n8n-workflow';
import { Container } from 'typedi';
import { Cipher } from './Cipher';

View File

@@ -1,3 +1,4 @@
import { Container } from '@n8n/di';
import glob from 'fast-glob';
import uniqBy from 'lodash/uniqBy';
import type {
@@ -19,7 +20,6 @@ import { ApplicationError, applyDeclarativeNodeOptionParameters, jsonParse } fro
import { readFileSync } from 'node:fs';
import { readFile } from 'node:fs/promises';
import * as path from 'path';
import Container from 'typedi';
import { Logger } from '@/logging/logger';

View File

@@ -1,9 +1,9 @@
import { Service } from '@n8n/di';
import { createHash, randomBytes } from 'crypto';
import { ApplicationError, jsonParse, ALPHABET, toResult } from 'n8n-workflow';
import { customAlphabet } from 'nanoid';
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
import path from 'path';
import { Service } from 'typedi';
import { Logger } from '@/logging/logger';

View File

@@ -13,6 +13,7 @@ import type {
OAuth2CredentialData,
} from '@n8n/client-oauth2';
import { ClientOAuth2 } from '@n8n/client-oauth2';
import { Container } from '@n8n/di';
import type { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios from 'axios';
import chardet from 'chardet';
@@ -93,7 +94,6 @@ import clientOAuth1 from 'oauth-1.0a';
import path from 'path';
import { stringify } from 'qs';
import { Readable } from 'stream';
import Container from 'typedi';
import url, { URL, URLSearchParams } from 'url';
import { Logger } from '@/logging/logger';

View File

@@ -1,3 +1,4 @@
import { Service } from '@n8n/di';
import { sign } from 'aws4';
import type { Request as Aws4Options, Credentials as Aws4Credentials } from 'aws4';
import axios from 'axios';
@@ -5,7 +6,6 @@ import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, Met
import { ApplicationError } from 'n8n-workflow';
import { createHash } from 'node:crypto';
import type { Readable } from 'stream';
import { Service } from 'typedi';
import { Logger } from '@/logging/logger';

View File

@@ -1,7 +1,7 @@
import { Service } from '@n8n/di';
import type { SSHCredentials } from 'n8n-workflow';
import { createHash } from 'node:crypto';
import { Client, type ConnectConfig } from 'ssh2';
import { Service } from 'typedi';
@Service()
export class SSHClientsManager {

View File

@@ -1,6 +1,6 @@
import { Service } from '@n8n/di';
import { CronJob } from 'cron';
import type { CronExpression, Workflow } from 'n8n-workflow';
import { Service } from 'typedi';
import { InstanceSettings } from './InstanceSettings';

View File

@@ -1,3 +1,4 @@
import { Service } from '@n8n/di';
import { ApplicationError } from 'n8n-workflow';
import type {
Workflow,
@@ -13,7 +14,6 @@ import type {
IExecuteResponsePromiseData,
IRun,
} from 'n8n-workflow';
import { Service } from 'typedi';
@Service()
export class TriggersAndPollers {

View File

@@ -2,6 +2,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
import { Container } from '@n8n/di';
import * as assert from 'assert/strict';
import { setMaxListeners } from 'events';
import { omit } from 'lodash';
@@ -53,7 +54,6 @@ import {
Node,
} from 'n8n-workflow';
import PCancelable from 'p-cancelable';
import Container from 'typedi';
import { ErrorReporter } from './error-reporter';
import { ExecuteContext, PollContext } from './node-execution-context';

View File

@@ -1,10 +1,10 @@
import { Service } from '@n8n/di';
import type { NodeOptions } from '@sentry/node';
import { close } from '@sentry/node';
import type { ErrorEvent, EventHint } from '@sentry/types';
import { AxiosError } from 'axios';
import { ApplicationError, ExecutionCancelledError, type ReportingOptions } from 'n8n-workflow';
import { createHash } from 'node:crypto';
import { Service } from 'typedi';
import type { InstanceType } from './InstanceSettings';
import { Logger } from './logging/logger';

View File

@@ -1,5 +1,6 @@
import type { LogScope } from '@n8n/config';
import { GlobalConfig } from '@n8n/config';
import { Service } from '@n8n/di';
import callsites from 'callsites';
import type { TransformableInfo } from 'logform';
import { LoggerProxy, LOG_LEVELS } from 'n8n-workflow';
@@ -11,7 +12,6 @@ import type {
} from 'n8n-workflow';
import path, { basename } from 'node:path';
import pc from 'picocolors';
import { Service } from 'typedi';
import winston from 'winston';
import { inDevelopment, inProduction } from '@/Constants';

View File

@@ -1,3 +1,4 @@
import { Container } from '@n8n/di';
import { mock } from 'jest-mock-extended';
import type {
Expression,
@@ -10,7 +11,6 @@ import type {
WorkflowExecuteMode,
} from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow';
import { Container } from 'typedi';
import { InstanceSettings } from '@/InstanceSettings';

View File

@@ -1,3 +1,4 @@
import { Container } from '@n8n/di';
import { captor, mock, type MockProxy } from 'jest-mock-extended';
import type {
IRunExecutionData,
@@ -15,7 +16,6 @@ import type {
IExecuteWorkflowInfo,
} from 'n8n-workflow';
import { ApplicationError, NodeHelpers, WAIT_INDEFINITELY } from 'n8n-workflow';
import Container from 'typedi';
import { BinaryDataService } from '@/BinaryData/BinaryData.service';

View File

@@ -1,3 +1,4 @@
import { Container } from '@n8n/di';
import { get } from 'lodash';
import type {
Workflow,
@@ -27,7 +28,6 @@ import {
WAIT_INDEFINITELY,
WorkflowDataProxy,
} from 'n8n-workflow';
import { Container } from 'typedi';
import { BinaryDataService } from '@/BinaryData/BinaryData.service';

View File

@@ -1,3 +1,4 @@
import { Container } from '@n8n/di';
import { get } from 'lodash';
import type {
FunctionsBase,
@@ -26,7 +27,6 @@ import {
NodeHelpers,
NodeOperationError,
} from 'n8n-workflow';
import { Container } from 'typedi';
import { HTTP_REQUEST_NODE_TYPE, HTTP_REQUEST_TOOL_NODE_TYPE } from '@/Constants';
import { Memoized } from '@/decorators';