mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor: Introduce explicit-member-accessibility
lint rule (#12325)
This commit is contained in:
parent
e5587ff11f
commit
95db031aa4
|
@ -2,7 +2,7 @@ import type { AxiosError, AxiosRequestConfig } from 'axios';
|
|||
import axios from 'axios';
|
||||
|
||||
export class N8nApiClient {
|
||||
constructor(public readonly apiBaseUrl: string) {}
|
||||
constructor(readonly apiBaseUrl: string) {}
|
||||
|
||||
async waitForInstanceToBecomeOnline(): Promise<void> {
|
||||
const HEALTH_ENDPOINT = 'healthz';
|
||||
|
|
|
@ -32,14 +32,14 @@ class MemoryChatBufferSingleton {
|
|||
this.memoryBuffer = new Map();
|
||||
}
|
||||
|
||||
public static getInstance(): MemoryChatBufferSingleton {
|
||||
static getInstance(): MemoryChatBufferSingleton {
|
||||
if (!MemoryChatBufferSingleton.instance) {
|
||||
MemoryChatBufferSingleton.instance = new MemoryChatBufferSingleton();
|
||||
}
|
||||
return MemoryChatBufferSingleton.instance;
|
||||
}
|
||||
|
||||
public async getMemory(
|
||||
async getMemory(
|
||||
sessionKey: string,
|
||||
memoryParams: BufferWindowMemoryInput,
|
||||
): Promise<BufferWindowMemory> {
|
||||
|
|
|
@ -11,7 +11,7 @@ export class MemoryVectorStoreManager {
|
|||
this.vectorStoreBuffer = new Map();
|
||||
}
|
||||
|
||||
public static getInstance(embeddings: Embeddings): MemoryVectorStoreManager {
|
||||
static getInstance(embeddings: Embeddings): MemoryVectorStoreManager {
|
||||
if (!MemoryVectorStoreManager.instance) {
|
||||
MemoryVectorStoreManager.instance = new MemoryVectorStoreManager(embeddings);
|
||||
} else {
|
||||
|
@ -27,7 +27,7 @@ export class MemoryVectorStoreManager {
|
|||
return MemoryVectorStoreManager.instance;
|
||||
}
|
||||
|
||||
public async getVectorStore(memoryKey: string): Promise<MemoryVectorStore> {
|
||||
async getVectorStore(memoryKey: string): Promise<MemoryVectorStore> {
|
||||
let vectorStoreInstance = this.vectorStoreBuffer.get(memoryKey);
|
||||
|
||||
if (!vectorStoreInstance) {
|
||||
|
@ -38,7 +38,7 @@ export class MemoryVectorStoreManager {
|
|||
return vectorStoreInstance;
|
||||
}
|
||||
|
||||
public async addDocuments(
|
||||
async addDocuments(
|
||||
memoryKey: string,
|
||||
documents: Document[],
|
||||
clearStore?: boolean,
|
||||
|
|
|
@ -21,7 +21,7 @@ export class BuiltInsParser {
|
|||
/**
|
||||
* Parses which built-in variables are accessed in the given code
|
||||
*/
|
||||
public parseUsedBuiltIns(code: string): Result<BuiltInsParserState, Error> {
|
||||
parseUsedBuiltIns(code: string): Result<BuiltInsParserState, Error> {
|
||||
return toResult(() => {
|
||||
const wrappedCode = `async function VmCodeWrapper() { ${code} }`;
|
||||
const ast = parse(wrappedCode, { ecmaVersion: 2025, sourceType: 'module' });
|
||||
|
|
|
@ -316,6 +316,11 @@ const config = (module.exports = {
|
|||
*/
|
||||
'@typescript-eslint/return-await': ['error', 'always'],
|
||||
|
||||
/**
|
||||
* https://typescript-eslint.io/rules/explicit-member-accessibility/
|
||||
*/
|
||||
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
|
||||
|
||||
// ----------------------------------
|
||||
// eslint-plugin-import
|
||||
// ----------------------------------
|
||||
|
|
|
@ -27,7 +27,7 @@ export class CollaborationState {
|
|||
* After how many minutes of inactivity a user should be removed
|
||||
* as being an active user of a workflow.
|
||||
*/
|
||||
public readonly inactivityCleanUpTime = 15 * Time.minutes.toMilliseconds;
|
||||
readonly inactivityCleanUpTime = 15 * Time.minutes.toMilliseconds;
|
||||
|
||||
constructor(private readonly cache: CacheService) {}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ export class TestRunRepository extends Repository<TestRun> {
|
|||
super(TestRun, dataSource.manager);
|
||||
}
|
||||
|
||||
public async createTestRun(testDefinitionId: string) {
|
||||
async createTestRun(testDefinitionId: string) {
|
||||
const testRun = this.create({
|
||||
status: 'new',
|
||||
testDefinition: { id: testDefinitionId },
|
||||
|
@ -21,15 +21,15 @@ export class TestRunRepository extends Repository<TestRun> {
|
|||
return await this.save(testRun);
|
||||
}
|
||||
|
||||
public async markAsRunning(id: string) {
|
||||
async markAsRunning(id: string) {
|
||||
return await this.update(id, { status: 'running', runAt: new Date() });
|
||||
}
|
||||
|
||||
public async markAsCompleted(id: string, metrics: AggregatedTestRunMetrics) {
|
||||
async markAsCompleted(id: string, metrics: AggregatedTestRunMetrics) {
|
||||
return await this.update(id, { status: 'completed', completedAt: new Date(), metrics });
|
||||
}
|
||||
|
||||
public async getMany(testDefinitionId: string, options: ListQuery.Options) {
|
||||
async getMany(testDefinitionId: string, options: ListQuery.Options) {
|
||||
const findManyOptions: FindManyOptions<TestRun> = {
|
||||
where: { testDefinition: { id: testDefinitionId } },
|
||||
order: { createdAt: 'DESC' },
|
||||
|
|
|
@ -71,7 +71,7 @@ export class SourceControlExportService {
|
|||
}
|
||||
}
|
||||
|
||||
public rmFilesFromExportFolder(filesToBeDeleted: Set<string>): Set<string> {
|
||||
rmFilesFromExportFolder(filesToBeDeleted: Set<string>): Set<string> {
|
||||
try {
|
||||
filesToBeDeleted.forEach((e) => rmSync(e));
|
||||
} catch (error) {
|
||||
|
|
|
@ -65,7 +65,7 @@ export class SourceControlImportService {
|
|||
);
|
||||
}
|
||||
|
||||
public async getRemoteVersionIdsFromFiles(): Promise<SourceControlWorkflowVersionId[]> {
|
||||
async getRemoteVersionIdsFromFiles(): Promise<SourceControlWorkflowVersionId[]> {
|
||||
const remoteWorkflowFiles = await glob('*.json', {
|
||||
cwd: this.workflowExportFolder,
|
||||
absolute: true,
|
||||
|
@ -91,7 +91,7 @@ export class SourceControlImportService {
|
|||
);
|
||||
}
|
||||
|
||||
public async getLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]> {
|
||||
async getLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]> {
|
||||
const localWorkflows = await Container.get(WorkflowRepository).find({
|
||||
select: ['id', 'name', 'versionId', 'updatedAt'],
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ export class SourceControlImportService {
|
|||
}) as SourceControlWorkflowVersionId[];
|
||||
}
|
||||
|
||||
public async getRemoteCredentialsFromFiles(): Promise<
|
||||
async getRemoteCredentialsFromFiles(): Promise<
|
||||
Array<ExportableCredential & { filename: string }>
|
||||
> {
|
||||
const remoteCredentialFiles = await glob('*.json', {
|
||||
|
@ -146,9 +146,7 @@ export class SourceControlImportService {
|
|||
>;
|
||||
}
|
||||
|
||||
public async getLocalCredentialsFromDb(): Promise<
|
||||
Array<ExportableCredential & { filename: string }>
|
||||
> {
|
||||
async getLocalCredentialsFromDb(): Promise<Array<ExportableCredential & { filename: string }>> {
|
||||
const localCredentials = await Container.get(CredentialsRepository).find({
|
||||
select: ['id', 'name', 'type'],
|
||||
});
|
||||
|
@ -160,7 +158,7 @@ export class SourceControlImportService {
|
|||
})) as Array<ExportableCredential & { filename: string }>;
|
||||
}
|
||||
|
||||
public async getRemoteVariablesFromFile(): Promise<Variables[]> {
|
||||
async getRemoteVariablesFromFile(): Promise<Variables[]> {
|
||||
const variablesFile = await glob(SOURCE_CONTROL_VARIABLES_EXPORT_FILE, {
|
||||
cwd: this.gitFolder,
|
||||
absolute: true,
|
||||
|
@ -174,11 +172,11 @@ export class SourceControlImportService {
|
|||
return [];
|
||||
}
|
||||
|
||||
public async getLocalVariablesFromDb(): Promise<Variables[]> {
|
||||
async getLocalVariablesFromDb(): Promise<Variables[]> {
|
||||
return await this.variablesService.getAllCached();
|
||||
}
|
||||
|
||||
public async getRemoteTagsAndMappingsFromFile(): Promise<{
|
||||
async getRemoteTagsAndMappingsFromFile(): Promise<{
|
||||
tags: TagEntity[];
|
||||
mappings: WorkflowTagMapping[];
|
||||
}> {
|
||||
|
@ -197,7 +195,7 @@ export class SourceControlImportService {
|
|||
return { tags: [], mappings: [] };
|
||||
}
|
||||
|
||||
public async getLocalTagsAndMappingsFromDb(): Promise<{
|
||||
async getLocalTagsAndMappingsFromDb(): Promise<{
|
||||
tags: TagEntity[];
|
||||
mappings: WorkflowTagMapping[];
|
||||
}> {
|
||||
|
@ -210,7 +208,7 @@ export class SourceControlImportService {
|
|||
return { tags: localTags, mappings: localMappings };
|
||||
}
|
||||
|
||||
public async importWorkflowFromWorkFolder(candidates: SourceControlledFile[], userId: string) {
|
||||
async importWorkflowFromWorkFolder(candidates: SourceControlledFile[], userId: string) {
|
||||
const personalProject =
|
||||
await Container.get(ProjectRepository).getPersonalProjectForUserOrFail(userId);
|
||||
const workflowManager = this.activeWorkflowManager;
|
||||
|
@ -297,7 +295,7 @@ export class SourceControlImportService {
|
|||
}>;
|
||||
}
|
||||
|
||||
public async importCredentialsFromWorkFolder(candidates: SourceControlledFile[], userId: string) {
|
||||
async importCredentialsFromWorkFolder(candidates: SourceControlledFile[], userId: string) {
|
||||
const personalProject =
|
||||
await Container.get(ProjectRepository).getPersonalProjectForUserOrFail(userId);
|
||||
const candidateIds = candidates.map((c) => c.id);
|
||||
|
@ -371,7 +369,7 @@ export class SourceControlImportService {
|
|||
return importCredentialsResult.filter((e) => e !== undefined);
|
||||
}
|
||||
|
||||
public async importTagsFromWorkFolder(candidate: SourceControlledFile) {
|
||||
async importTagsFromWorkFolder(candidate: SourceControlledFile) {
|
||||
let mappedTags;
|
||||
try {
|
||||
this.logger.debug(`Importing tags from file ${candidate.file}`);
|
||||
|
@ -433,7 +431,7 @@ export class SourceControlImportService {
|
|||
return mappedTags;
|
||||
}
|
||||
|
||||
public async importVariablesFromWorkFolder(
|
||||
async importVariablesFromWorkFolder(
|
||||
candidate: SourceControlledFile,
|
||||
valueOverrides?: {
|
||||
[key: string]: string;
|
||||
|
|
|
@ -41,7 +41,7 @@ export class SourceControlPreferencesService {
|
|||
this.sshKeyName = path.join(this.sshFolder, SOURCE_CONTROL_SSH_KEY_NAME);
|
||||
}
|
||||
|
||||
public get sourceControlPreferences(): SourceControlPreferences {
|
||||
get sourceControlPreferences(): SourceControlPreferences {
|
||||
return {
|
||||
...this._sourceControlPreferences,
|
||||
connected: this._sourceControlPreferences.connected ?? false,
|
||||
|
@ -49,14 +49,14 @@ export class SourceControlPreferencesService {
|
|||
}
|
||||
|
||||
// merge the new preferences with the existing preferences when setting
|
||||
public set sourceControlPreferences(preferences: Partial<SourceControlPreferences>) {
|
||||
set sourceControlPreferences(preferences: Partial<SourceControlPreferences>) {
|
||||
this._sourceControlPreferences = SourceControlPreferences.merge(
|
||||
preferences,
|
||||
this._sourceControlPreferences,
|
||||
);
|
||||
}
|
||||
|
||||
public isSourceControlSetup() {
|
||||
isSourceControlSetup() {
|
||||
return (
|
||||
this.isSourceControlLicensedAndEnabled() &&
|
||||
this.getPreferences().repositoryUrl &&
|
||||
|
|
|
@ -81,7 +81,7 @@ export class SourceControlService {
|
|||
});
|
||||
}
|
||||
|
||||
public async sanityCheck(): Promise<void> {
|
||||
async sanityCheck(): Promise<void> {
|
||||
try {
|
||||
const foldersExisted = sourceControlFoldersExistCheck(
|
||||
[this.gitFolder, this.sshFolder],
|
||||
|
|
|
@ -186,7 +186,7 @@ export class TestRunnerService {
|
|||
/**
|
||||
* Creates a new test run for the given test definition.
|
||||
*/
|
||||
public async runTest(user: User, test: TestDefinition): Promise<void> {
|
||||
async runTest(user: User, test: TestDefinition): Promise<void> {
|
||||
const workflow = await this.workflowRepository.findById(test.workflowId);
|
||||
assert(workflow, 'Workflow not found');
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ export class MessageEventBusLogWriter {
|
|||
this.globalConfig = Container.get(GlobalConfig);
|
||||
}
|
||||
|
||||
public get worker(): Worker | undefined {
|
||||
get worker(): Worker | undefined {
|
||||
return this._worker;
|
||||
}
|
||||
|
||||
|
|
|
@ -504,7 +504,7 @@ export class ExecutionService {
|
|||
}
|
||||
}
|
||||
|
||||
public async annotate(
|
||||
async annotate(
|
||||
executionId: string,
|
||||
updateData: ExecutionRequest.ExecutionUpdatePayload,
|
||||
sharedWorkflowIds: string[],
|
||||
|
|
|
@ -11,15 +11,15 @@ import { mockInstance } from '@test/mocking';
|
|||
jest.useFakeTimers();
|
||||
|
||||
class MockWebSocket extends EventEmitter {
|
||||
public isAlive = true;
|
||||
isAlive = true;
|
||||
|
||||
public ping = jest.fn();
|
||||
ping = jest.fn();
|
||||
|
||||
public send = jest.fn();
|
||||
send = jest.fn();
|
||||
|
||||
public terminate = jest.fn();
|
||||
terminate = jest.fn();
|
||||
|
||||
public close = jest.fn();
|
||||
close = jest.fn();
|
||||
}
|
||||
|
||||
const createMockWebSocket = () => new MockWebSocket() as unknown as jest.Mocked<WebSocket>;
|
||||
|
|
|
@ -36,7 +36,7 @@ const useWebSockets = config.getEnv('push.backend') === 'websocket';
|
|||
*/
|
||||
@Service()
|
||||
export class Push extends TypedEmitter<PushEvents> {
|
||||
public isBidirectional = useWebSockets;
|
||||
isBidirectional = useWebSockets;
|
||||
|
||||
private backend = useWebSockets ? Container.get(WebSocketPush) : Container.get(SSEPush);
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ import type { TaskRunner } from '@n8n/task-runner';
|
|||
import { ApplicationError } from 'n8n-workflow';
|
||||
|
||||
export class TaskRunnerDisconnectedError extends ApplicationError {
|
||||
public description: string;
|
||||
description: string;
|
||||
|
||||
constructor(
|
||||
public readonly runnerId: TaskRunner['id'],
|
||||
readonly runnerId: TaskRunner['id'],
|
||||
isCloudDeployment: boolean,
|
||||
) {
|
||||
super('Node execution failed');
|
||||
|
|
|
@ -3,10 +3,10 @@ import { ApplicationError } from 'n8n-workflow';
|
|||
import type { TaskRunner } from '../task-broker.service';
|
||||
|
||||
export class TaskRunnerOomError extends ApplicationError {
|
||||
public description: string;
|
||||
description: string;
|
||||
|
||||
constructor(
|
||||
public readonly runnerId: TaskRunner['id'],
|
||||
readonly runnerId: TaskRunner['id'],
|
||||
isCloudDeployment: boolean,
|
||||
) {
|
||||
super('Node ran out of memory.', { level: 'error' });
|
||||
|
|
|
@ -2,8 +2,8 @@ import { ApplicationError } from 'n8n-workflow';
|
|||
|
||||
export class TaskRunnerRestartLoopError extends ApplicationError {
|
||||
constructor(
|
||||
public readonly howManyTimes: number,
|
||||
public readonly timePeriodMs: number,
|
||||
readonly howManyTimes: number,
|
||||
readonly timePeriodMs: number,
|
||||
) {
|
||||
const message = `Task runner has restarted ${howManyTimes} times within ${timePeriodMs / 1000} seconds. This is an abnormally high restart rate that suggests a bug or other issue is preventing your runner process from starting up. If this issues persists, please file a report at: https://github.com/n8n-io/n8n/issues`;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import type { ChildProcess } from 'node:child_process';
|
|||
* memory (OOMs).
|
||||
*/
|
||||
export class NodeProcessOomDetector {
|
||||
public get didProcessOom() {
|
||||
get didProcessOom() {
|
||||
return this._didProcessOom;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ export class SlidingWindowSignal<TEvents, TEventName extends keyof TEvents & str
|
|||
* milliseconds for the event to be emitted. `null` is returned
|
||||
* if no event is emitted within the window.
|
||||
*/
|
||||
public async getSignal(): Promise<TEvents[TEventName] | null> {
|
||||
async getSignal(): Promise<TEvents[TEventName] | null> {
|
||||
const timeSinceLastEvent = Date.now() - this.lastSignalTime;
|
||||
if (timeSinceLastEvent <= this.windowSizeInMs) return this.lastSignal;
|
||||
|
||||
|
|
|
@ -28,17 +28,17 @@ export type TaskRunnerProcessEventMap = {
|
|||
*/
|
||||
@Service()
|
||||
export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
public get isRunning() {
|
||||
get isRunning() {
|
||||
return this.process !== null;
|
||||
}
|
||||
|
||||
/** The process ID of the task runner process */
|
||||
public get pid() {
|
||||
get pid() {
|
||||
return this.process?.pid;
|
||||
}
|
||||
|
||||
/** Promise that resolves when the process has exited */
|
||||
public get runPromise() {
|
||||
get runPromise() {
|
||||
return this._runPromise;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ export class TaskRunnerServer {
|
|||
|
||||
readonly app: express.Application;
|
||||
|
||||
public get port() {
|
||||
get port() {
|
||||
return (this.server?.address() as AddressInfo)?.port;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ export class SamlService {
|
|||
},
|
||||
};
|
||||
|
||||
public get samlPreferences(): SamlPreferences {
|
||||
get samlPreferences(): SamlPreferences {
|
||||
return {
|
||||
...this._samlPreferences,
|
||||
loginEnabled: isSamlLoginEnabled(),
|
||||
|
|
|
@ -14,7 +14,7 @@ jest.unmock('node:fs');
|
|||
|
||||
/** Test server for testing the form data parsing */
|
||||
class TestServer {
|
||||
public agent: TestAgent;
|
||||
agent: TestAgent;
|
||||
|
||||
private app: express.Application;
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ class AIParametersParser {
|
|||
* Creates a DynamicStructuredTool from a node.
|
||||
* @returns A DynamicStructuredTool instance.
|
||||
*/
|
||||
public createTool(): DynamicStructuredTool {
|
||||
createTool(): DynamicStructuredTool {
|
||||
const { node, nodeType } = this.options;
|
||||
const schema = this.getSchema();
|
||||
const description = this.getDescription();
|
||||
|
|
|
@ -53,7 +53,7 @@ describe('Memoized Decorator', () => {
|
|||
class InvalidClass {
|
||||
// @ts-expect-error this code will fail at compile time and at runtime
|
||||
@Memoized
|
||||
public normalProperty = 42;
|
||||
normalProperty = 42;
|
||||
}
|
||||
new InvalidClass();
|
||||
}).toThrow(AssertionError);
|
||||
|
|
Loading…
Reference in a new issue