From 5db9c46043ead91c49c9c0b87d283e8ca360ecc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 21 Dec 2022 10:46:26 +0100 Subject: [PATCH] ci: Break most of the circular dependencies in code (no-changelog) (#4990) --- .../handlers/credentials/credentials.service.ts | 6 +++--- .../v1/handlers/workflows/workflows.handler.ts | 8 ++++---- packages/cli/src/Server.ts | 2 +- packages/cli/src/api/workflowStats.api.ts | 8 ++++---- .../cli/src/credentials/credentials.service.ts | 8 ++++---- .../cli/src/credentials/oauth2Credential.api.ts | 6 +++--- .../src/databases/entities/CredentialsEntity.ts | 4 ++-- .../cli/src/databases/entities/InstalledNodes.ts | 7 ++----- .../src/databases/entities/InstalledPackages.ts | 4 ++-- packages/cli/src/databases/entities/Role.ts | 12 ++++++------ .../src/databases/entities/SharedCredentials.ts | 12 ++++++------ .../cli/src/databases/entities/SharedWorkflow.ts | 12 ++++++------ packages/cli/src/databases/entities/TagEntity.ts | 6 +++--- packages/cli/src/databases/entities/User.ts | 12 ++++++------ .../cli/src/databases/entities/WorkflowEntity.ts | 15 ++++++--------- .../src/databases/entities/WorkflowStatistics.ts | 4 ++-- packages/cli/src/events/WorkflowStatistics.ts | 7 ++++--- packages/cli/src/executions/executions.service.ts | 7 ++++--- packages/cli/src/license/License.service.ts | 3 ++- packages/cli/src/license/license.controller.ts | 9 +++------ .../cli/src/workflows/workflows.controller.ee.ts | 6 +++--- .../cli/src/workflows/workflows.controller.ts | 10 +++++----- packages/cli/src/workflows/workflows.services.ts | 8 ++++---- packages/core/src/NodeExecuteFunctions.ts | 2 +- packages/core/src/WorkflowExecute.ts | 4 ++-- packages/node-dev/src/Build.ts | 2 +- packages/node-dev/src/index.ts | 1 - .../ActionNetwork/descriptions/SharedFields.ts | 6 +++--- .../nodes-base/nodes/ActionNetwork/types.d.ts | 6 ++++-- .../Google/Sheet/v2/helpers/GoogleSheets.utils.ts | 2 +- packages/nodes-base/nodes/SeaTable/Interfaces.ts | 2 +- .../nodes/Todoist/v1/OperationHandler.ts | 2 +- .../nodes/Todoist/v2/OperationHandler.ts | 2 +- packages/workflow/src/ExpressionError.ts | 2 +- packages/workflow/src/Interfaces.ts | 2 +- packages/workflow/src/WorkflowDataProxy.ts | 6 +++--- 36 files changed, 105 insertions(+), 110 deletions(-) diff --git a/packages/cli/src/PublicApi/v1/handlers/credentials/credentials.service.ts b/packages/cli/src/PublicApi/v1/handlers/credentials/credentials.service.ts index de1fb8bd1e..5d222cf8b1 100644 --- a/packages/cli/src/PublicApi/v1/handlers/credentials/credentials.service.ts +++ b/packages/cli/src/PublicApi/v1/handlers/credentials/credentials.service.ts @@ -10,7 +10,7 @@ import type { ICredentialsDb } from '@/Interfaces'; import { CredentialsEntity } from '@db/entities/CredentialsEntity'; import { SharedCredentials } from '@db/entities/SharedCredentials'; import { User } from '@db/entities/User'; -import { externalHooks } from '@/Server'; +import { ExternalHooks } from '@/ExternalHooks'; import { IDependency, IJsonSchema } from '../../../types'; import { CredentialRequest } from '@/requests'; @@ -74,7 +74,7 @@ export async function saveCredential( scope: 'credential', }); - await externalHooks.run('credentials.create', [encryptedData]); + await ExternalHooks().run('credentials.create', [encryptedData]); return Db.transaction(async (transactionManager) => { const savedCredential = await transactionManager.save(credential); @@ -96,7 +96,7 @@ export async function saveCredential( } export async function removeCredential(credentials: CredentialsEntity): Promise { - await externalHooks.run('credentials.delete', [credentials.id]); + await ExternalHooks().run('credentials.delete', [credentials.id]); return Db.collections.Credentials.remove(credentials); } diff --git a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts index 737d0e670a..b6a28fe6cb 100644 --- a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts +++ b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts @@ -7,7 +7,7 @@ import * as ActiveWorkflowRunner from '@/ActiveWorkflowRunner'; import config from '@/config'; import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { InternalHooksManager } from '@/InternalHooksManager'; -import { externalHooks } from '@/Server'; +import { ExternalHooks } from '@/ExternalHooks'; import { addNodeIds, replaceInvalidCredentials } from '@/WorkflowHelpers'; import { WorkflowRequest } from '../../../types'; import { authorize, validCursor } from '../../shared/middlewares/global.middleware'; @@ -49,7 +49,7 @@ export = { const createdWorkflow = await createWorkflow(workflow, req.user, role); - await externalHooks.run('workflow.afterCreate', [createdWorkflow]); + await ExternalHooks().run('workflow.afterCreate', [createdWorkflow]); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, createdWorkflow, true); return res.json(createdWorkflow); @@ -76,7 +76,7 @@ export = { await Db.collections.Workflow.delete(id); void InternalHooksManager.getInstance().onWorkflowDeleted(req.user.id, id.toString(), true); - await externalHooks.run('workflow.afterDelete', [id.toString()]); + await ExternalHooks().run('workflow.afterDelete', [id.toString()]); return res.json(sharedWorkflow.workflow); }, @@ -219,7 +219,7 @@ export = { const updatedWorkflow = await getWorkflowById(sharedWorkflow.workflowId); - await externalHooks.run('workflow.afterUpdate', [updateData]); + await ExternalHooks().run('workflow.afterUpdate', [updateData]); void InternalHooksManager.getInstance().onWorkflowSaved(req.user.id, updateData, true); return res.json(updatedWorkflow); diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 01ce1e7900..fab952e0f3 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -165,7 +165,7 @@ require('body-parser-xml')(bodyParser); const exec = promisify(callbackExec); -export const externalHooks: IExternalHooksClass = ExternalHooks(); +const externalHooks: IExternalHooksClass = ExternalHooks(); class App { app: express.Application; diff --git a/packages/cli/src/api/workflowStats.api.ts b/packages/cli/src/api/workflowStats.api.ts index a2bb6da707..fac958cc62 100644 --- a/packages/cli/src/api/workflowStats.api.ts +++ b/packages/cli/src/api/workflowStats.api.ts @@ -2,13 +2,13 @@ import { User } from '@/databases/entities/User'; import { whereClause } from '@/UserManagement/UserManagementHelper'; import express from 'express'; import { LoggerProxy } from 'n8n-workflow'; -import { - Db, +import * as Db from '@/Db'; +import * as ResponseHelper from '@/ResponseHelper'; +import type { IWorkflowStatisticsCounts, IWorkflowStatisticsDataLoaded, IWorkflowStatisticsTimestamps, - ResponseHelper, -} from '..'; +} from '@/Interfaces'; import { StatisticsNames } from '../databases/entities/WorkflowStatistics'; import { getLogger } from '../Logger'; import { ExecutionRequest } from '../requests'; diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index 4ce18c4d36..50905b3be1 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -20,7 +20,7 @@ import { CREDENTIAL_BLANKING_VALUE, RESPONSE_ERROR_MESSAGES } from '@/constants' import { CredentialsEntity } from '@db/entities/CredentialsEntity'; import { SharedCredentials } from '@db/entities/SharedCredentials'; import { validateEntity } from '@/GenericHelpers'; -import { externalHooks } from '../Server'; +import { ExternalHooks } from '@/ExternalHooks'; import type { User } from '@db/entities/User'; import type { CredentialRequest } from '@/requests'; @@ -234,7 +234,7 @@ export class CredentialsService { credentialId: string, newCredentialData: ICredentialsDb, ): Promise { - await externalHooks.run('credentials.update', [newCredentialData]); + await ExternalHooks().run('credentials.update', [newCredentialData]); // Update the credentials in DB await Db.collections.Credentials.update(credentialId, newCredentialData); @@ -253,7 +253,7 @@ export class CredentialsService { const newCredential = new CredentialsEntity(); Object.assign(newCredential, credential, encryptedData); - await externalHooks.run('credentials.create', [encryptedData]); + await ExternalHooks().run('credentials.create', [encryptedData]); const role = await Db.collections.Role.findOneOrFail({ name: 'owner', @@ -285,7 +285,7 @@ export class CredentialsService { } static async delete(credentials: CredentialsEntity): Promise { - await externalHooks.run('credentials.delete', [credentials.id]); + await ExternalHooks().run('credentials.delete', [credentials.id]); await Db.collections.Credentials.remove(credentials); } diff --git a/packages/cli/src/credentials/oauth2Credential.api.ts b/packages/cli/src/credentials/oauth2Credential.api.ts index 452970ee04..a46018e659 100644 --- a/packages/cli/src/credentials/oauth2Credential.api.ts +++ b/packages/cli/src/credentials/oauth2Credential.api.ts @@ -27,7 +27,7 @@ import { } from '@/CredentialsHelper'; import { getLogger } from '@/Logger'; import { OAuthRequest } from '@/requests'; -import { externalHooks } from '@/Server'; +import { ExternalHooks } from '@/ExternalHooks'; import config from '@/config'; import { getInstanceBaseUrl } from '@/UserManagement/UserManagementHelper'; @@ -129,7 +129,7 @@ oauth2CredentialController.get( state: stateEncodedStr, }; - await externalHooks.run('oauth2.authenticate', [oAuthOptions]); + await ExternalHooks().run('oauth2.authenticate', [oAuthOptions]); const oAuthObj = new ClientOAuth2(oAuthOptions); @@ -281,7 +281,7 @@ oauth2CredentialController.get( delete oAuth2Parameters.clientSecret; } - await externalHooks.run('oauth2.callback', [oAuth2Parameters]); + await ExternalHooks().run('oauth2.callback', [oAuth2Parameters]); const oAuthObj = new ClientOAuth2(oAuth2Parameters); diff --git a/packages/cli/src/databases/entities/CredentialsEntity.ts b/packages/cli/src/databases/entities/CredentialsEntity.ts index 76eadcf03e..70fcde7051 100644 --- a/packages/cli/src/databases/entities/CredentialsEntity.ts +++ b/packages/cli/src/databases/entities/CredentialsEntity.ts @@ -1,7 +1,7 @@ import type { ICredentialNodeAccess } from 'n8n-workflow'; import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { IsArray, IsObject, IsString, Length } from 'class-validator'; -import { SharedCredentials } from './SharedCredentials'; +import type { SharedCredentials } from './SharedCredentials'; import { AbstractEntity, jsonColumnType } from './AbstractEntity'; import type { ICredentialsDb } from '@/Interfaces'; @@ -28,7 +28,7 @@ export class CredentialsEntity extends AbstractEntity implements ICredentialsDb }) type: string; - @OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.credentials) + @OneToMany('SharedCredentials', 'credentials') shared: SharedCredentials[]; @Column(jsonColumnType) diff --git a/packages/cli/src/databases/entities/InstalledNodes.ts b/packages/cli/src/databases/entities/InstalledNodes.ts index deec41b031..6aec662c78 100644 --- a/packages/cli/src/databases/entities/InstalledNodes.ts +++ b/packages/cli/src/databases/entities/InstalledNodes.ts @@ -1,5 +1,5 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'; -import { InstalledPackages } from './InstalledPackages'; +import type { InstalledPackages } from './InstalledPackages'; @Entity() export class InstalledNodes { @@ -12,10 +12,7 @@ export class InstalledNodes { @Column() latestVersion: string; - @ManyToOne( - () => InstalledPackages, - (installedPackages: InstalledPackages) => installedPackages.installedNodes, - ) + @ManyToOne('InstalledPackages', 'installedNodes') @JoinColumn({ name: 'package', referencedColumnName: 'packageName' }) package: InstalledPackages; } diff --git a/packages/cli/src/databases/entities/InstalledPackages.ts b/packages/cli/src/databases/entities/InstalledPackages.ts index b339fba00f..ec406ca5d6 100644 --- a/packages/cli/src/databases/entities/InstalledPackages.ts +++ b/packages/cli/src/databases/entities/InstalledPackages.ts @@ -1,5 +1,5 @@ import { Column, Entity, JoinColumn, OneToMany, PrimaryColumn } from 'typeorm'; -import { InstalledNodes } from './InstalledNodes'; +import type { InstalledNodes } from './InstalledNodes'; import { AbstractEntity } from './AbstractEntity'; @Entity() @@ -16,7 +16,7 @@ export class InstalledPackages extends AbstractEntity { @Column() authorEmail?: string; - @OneToMany(() => InstalledNodes, (installedNode) => installedNode.package) + @OneToMany('InstalledNodes', 'package') @JoinColumn({ referencedColumnName: 'package' }) installedNodes: InstalledNodes[]; } diff --git a/packages/cli/src/databases/entities/Role.ts b/packages/cli/src/databases/entities/Role.ts index 49851d30b1..da9294a90a 100644 --- a/packages/cli/src/databases/entities/Role.ts +++ b/packages/cli/src/databases/entities/Role.ts @@ -1,9 +1,9 @@ import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm'; import { IsString, Length } from 'class-validator'; -import { User } from './User'; -import { SharedWorkflow } from './SharedWorkflow'; -import { SharedCredentials } from './SharedCredentials'; +import type { User } from './User'; +import type { SharedWorkflow } from './SharedWorkflow'; +import type { SharedCredentials } from './SharedCredentials'; import { AbstractEntity } from './AbstractEntity'; export type RoleNames = 'owner' | 'member' | 'user' | 'editor'; @@ -23,12 +23,12 @@ export class Role extends AbstractEntity { @Column() scope: RoleScopes; - @OneToMany(() => User, (user) => user.globalRole) + @OneToMany('User', 'globalRole') globalForUsers: User[]; - @OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.role) + @OneToMany('SharedWorkflow', 'role') sharedWorkflows: SharedWorkflow[]; - @OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.role) + @OneToMany('SharedCredentials', 'role') sharedCredentials: SharedCredentials[]; } diff --git a/packages/cli/src/databases/entities/SharedCredentials.ts b/packages/cli/src/databases/entities/SharedCredentials.ts index 8ff8e518f5..79f7035608 100644 --- a/packages/cli/src/databases/entities/SharedCredentials.ts +++ b/packages/cli/src/databases/entities/SharedCredentials.ts @@ -1,21 +1,21 @@ import { Entity, ManyToOne, RelationId } from 'typeorm'; -import { CredentialsEntity } from './CredentialsEntity'; -import { User } from './User'; -import { Role } from './Role'; +import type { CredentialsEntity } from './CredentialsEntity'; +import type { User } from './User'; +import type { Role } from './Role'; import { AbstractEntity } from './AbstractEntity'; @Entity() export class SharedCredentials extends AbstractEntity { - @ManyToOne(() => Role, (role) => role.sharedCredentials, { nullable: false }) + @ManyToOne('Role', 'sharedCredentials', { nullable: false }) role: Role; - @ManyToOne(() => User, (user) => user.sharedCredentials, { primary: true }) + @ManyToOne('User', 'sharedCredentials', { primary: true }) user: User; @RelationId((sharedCredential: SharedCredentials) => sharedCredential.user) userId: string; - @ManyToOne(() => CredentialsEntity, (credentials) => credentials.shared, { + @ManyToOne('CredentialsEntity', 'shared', { primary: true, onDelete: 'CASCADE', }) diff --git a/packages/cli/src/databases/entities/SharedWorkflow.ts b/packages/cli/src/databases/entities/SharedWorkflow.ts index 69e9d074c3..bda0313987 100644 --- a/packages/cli/src/databases/entities/SharedWorkflow.ts +++ b/packages/cli/src/databases/entities/SharedWorkflow.ts @@ -1,21 +1,21 @@ import { Entity, ManyToOne, RelationId } from 'typeorm'; -import { WorkflowEntity } from './WorkflowEntity'; -import { User } from './User'; -import { Role } from './Role'; +import type { WorkflowEntity } from './WorkflowEntity'; +import type { User } from './User'; +import type { Role } from './Role'; import { AbstractEntity } from './AbstractEntity'; @Entity() export class SharedWorkflow extends AbstractEntity { - @ManyToOne(() => Role, (role) => role.sharedWorkflows, { nullable: false }) + @ManyToOne('Role', 'sharedWorkflows', { nullable: false }) role: Role; - @ManyToOne(() => User, (user) => user.sharedWorkflows, { primary: true }) + @ManyToOne('User', 'sharedWorkflows', { primary: true }) user: User; @RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user) userId: string; - @ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, { + @ManyToOne('WorkflowEntity', 'shared', { primary: true, onDelete: 'CASCADE', }) diff --git a/packages/cli/src/databases/entities/TagEntity.ts b/packages/cli/src/databases/entities/TagEntity.ts index 398059ad34..4590bc311a 100644 --- a/packages/cli/src/databases/entities/TagEntity.ts +++ b/packages/cli/src/databases/entities/TagEntity.ts @@ -1,9 +1,9 @@ import { Column, Entity, Generated, Index, ManyToMany, PrimaryColumn } from 'typeorm'; import { IsString, Length } from 'class-validator'; -import { ITagDb } from '@/Interfaces'; +import type { ITagDb } from '@/Interfaces'; import { idStringifier } from '../utils/transformers'; -import { WorkflowEntity } from './WorkflowEntity'; +import type { WorkflowEntity } from './WorkflowEntity'; import { AbstractEntity } from './AbstractEntity'; @Entity() @@ -20,6 +20,6 @@ export class TagEntity extends AbstractEntity implements ITagDb { @Length(1, 24, { message: 'Tag name must be $constraint1 to $constraint2 characters long.' }) name: string; - @ManyToMany(() => WorkflowEntity, (workflow) => workflow.tags) + @ManyToMany('WorkflowEntity', 'tags') workflows: WorkflowEntity[]; } diff --git a/packages/cli/src/databases/entities/User.ts b/packages/cli/src/databases/entities/User.ts index cbd143dba2..e6867b17bf 100644 --- a/packages/cli/src/databases/entities/User.ts +++ b/packages/cli/src/databases/entities/User.ts @@ -12,9 +12,9 @@ import { } from 'typeorm'; import { IsEmail, IsString, Length } from 'class-validator'; import type { IUser } from 'n8n-workflow'; -import { Role } from './Role'; -import { SharedWorkflow } from './SharedWorkflow'; -import { SharedCredentials } from './SharedCredentials'; +import type { Role } from './Role'; +import type { SharedWorkflow } from './SharedWorkflow'; +import type { SharedCredentials } from './SharedCredentials'; import { NoXss } from '../utils/customValidators'; import { objectRetriever, lowerCaser } from '../utils/transformers'; import { AbstractEntity, jsonColumnType } from './AbstractEntity'; @@ -74,16 +74,16 @@ export class User extends AbstractEntity implements IUser { }) settings: IUserSettings | null; - @ManyToOne(() => Role, (role) => role.globalForUsers, { + @ManyToOne('Role', 'globalForUsers', { cascade: true, nullable: false, }) globalRole: Role; - @OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.user) + @OneToMany('SharedWorkflow', 'user') sharedWorkflows: SharedWorkflow[]; - @OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.user) + @OneToMany('SharedCredentials', 'user') sharedCredentials: SharedCredentials[]; @BeforeInsert() diff --git a/packages/cli/src/databases/entities/WorkflowEntity.ts b/packages/cli/src/databases/entities/WorkflowEntity.ts index ccec65832f..74218a0f43 100644 --- a/packages/cli/src/databases/entities/WorkflowEntity.ts +++ b/packages/cli/src/databases/entities/WorkflowEntity.ts @@ -21,11 +21,11 @@ import { } from 'typeorm'; import config from '@/config'; -import { TagEntity } from './TagEntity'; -import { SharedWorkflow } from './SharedWorkflow'; +import type { TagEntity } from './TagEntity'; +import type { SharedWorkflow } from './SharedWorkflow'; +import type { WorkflowStatistics } from './WorkflowStatistics'; import { objectRetriever, sqlite } from '../utils/transformers'; import { AbstractEntity, jsonColumnType } from './AbstractEntity'; -import { WorkflowStatistics } from './WorkflowStatistics'; import type { IWorkflowDb } from '@/Interfaces'; @Entity() @@ -63,7 +63,7 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb { }) staticData?: IDataObject; - @ManyToMany(() => TagEntity, (tag) => tag.workflows) + @ManyToMany('TagEntity', 'workflows') @JoinTable({ name: 'workflows_tags', // table name for the junction table of this relation joinColumn: { @@ -77,13 +77,10 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb { }) tags?: TagEntity[]; - @OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow) + @OneToMany('SharedWorkflow', 'workflow') shared: SharedWorkflow[]; - @OneToMany( - () => WorkflowStatistics, - (workflowStatistics: WorkflowStatistics) => workflowStatistics.workflow, - ) + @OneToMany('WorkflowStatistics', 'workflow') @JoinColumn({ referencedColumnName: 'workflow' }) statistics: WorkflowStatistics[]; diff --git a/packages/cli/src/databases/entities/WorkflowStatistics.ts b/packages/cli/src/databases/entities/WorkflowStatistics.ts index 6ef1e1d6bf..8378081604 100644 --- a/packages/cli/src/databases/entities/WorkflowStatistics.ts +++ b/packages/cli/src/databases/entities/WorkflowStatistics.ts @@ -1,6 +1,6 @@ import { Column, Entity, RelationId, ManyToOne, PrimaryColumn } from 'typeorm'; import { datetimeColumnType } from './AbstractEntity'; -import { WorkflowEntity } from './WorkflowEntity'; +import type { WorkflowEntity } from './WorkflowEntity'; export enum StatisticsNames { productionSuccess = 'production_success', @@ -20,7 +20,7 @@ export class WorkflowStatistics { @PrimaryColumn({ length: 128 }) name: StatisticsNames; - @ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, { + @ManyToOne('WorkflowEntity', 'shared', { primary: true, onDelete: 'CASCADE', }) diff --git a/packages/cli/src/events/WorkflowStatistics.ts b/packages/cli/src/events/WorkflowStatistics.ts index df2cddda25..cd2d51335d 100644 --- a/packages/cli/src/events/WorkflowStatistics.ts +++ b/packages/cli/src/events/WorkflowStatistics.ts @@ -1,7 +1,8 @@ import { INode, IRun, IWorkflowBase, LoggerProxy } from 'n8n-workflow'; -import { Db, InternalHooksManager } from '..'; -import { StatisticsNames } from '../databases/entities/WorkflowStatistics'; -import { getWorkflowOwner } from '../UserManagement/UserManagementHelper'; +import * as Db from '@/Db'; +import { InternalHooksManager } from '@/InternalHooksManager'; +import { StatisticsNames } from '@/databases/entities/WorkflowStatistics'; +import { getWorkflowOwner } from '@/UserManagement/UserManagementHelper'; export async function workflowExecutionCompleted( workflowData: IWorkflowBase, diff --git a/packages/cli/src/executions/executions.service.ts b/packages/cli/src/executions/executions.service.ts index 8ca2ef2540..5e47eb0b65 100644 --- a/packages/cli/src/executions/executions.service.ts +++ b/packages/cli/src/executions/executions.service.ts @@ -8,7 +8,6 @@ import { FindOperator, In, IsNull, LessThanOrEqual, Not, Raw } from 'typeorm'; import * as ActiveExecutions from '@/ActiveExecutions'; import config from '@/config'; import { User } from '@/databases/entities/User'; -import { DEFAULT_EXECUTIONS_GET_ALL_LIMIT } from '@/GenericHelpers'; import { IExecutionFlattedResponse, IExecutionResponse, @@ -22,7 +21,9 @@ import type { ExecutionRequest } from '@/requests'; import * as ResponseHelper from '@/ResponseHelper'; import { getSharedWorkflowIds } from '@/WorkflowHelpers'; import { WorkflowRunner } from '@/WorkflowRunner'; -import { DatabaseType, Db, GenericHelpers } from '..'; +import type { DatabaseType } from '@/Interfaces'; +import * as Db from '@/Db'; +import * as GenericHelpers from '@/GenericHelpers'; interface IGetExecutionsQueryFilter { id?: FindOperator; @@ -174,7 +175,7 @@ export class ExecutionsService { const limit = req.query.limit ? parseInt(req.query.limit, 10) - : DEFAULT_EXECUTIONS_GET_ALL_LIMIT; + : GenericHelpers.DEFAULT_EXECUTIONS_GET_ALL_LIMIT; const executingWorkflowIds: string[] = []; diff --git a/packages/cli/src/license/License.service.ts b/packages/cli/src/license/License.service.ts index ae2487ea74..df3aa99f9c 100644 --- a/packages/cli/src/license/License.service.ts +++ b/packages/cli/src/license/License.service.ts @@ -1,5 +1,6 @@ import { getLicense } from '@/License'; -import { Db, ILicenseReadResponse } from '..'; +import type { ILicenseReadResponse } from '@/Interfaces'; +import * as Db from '@/Db'; export class LicenseService { static async getActiveTriggerCount(): Promise { diff --git a/packages/cli/src/license/license.controller.ts b/packages/cli/src/license/license.controller.ts index aab091c9ce..47bd365769 100644 --- a/packages/cli/src/license/license.controller.ts +++ b/packages/cli/src/license/license.controller.ts @@ -4,12 +4,9 @@ import express from 'express'; import { LoggerProxy } from 'n8n-workflow'; import { getLogger } from '@/Logger'; -import { - ILicensePostResponse, - ILicenseReadResponse, - InternalHooksManager, - ResponseHelper, -} from '..'; +import * as ResponseHelper from '@/ResponseHelper'; +import { InternalHooksManager } from '@/InternalHooksManager'; +import type { ILicensePostResponse, ILicenseReadResponse } from '@/Interfaces'; import { LicenseService } from './License.service'; import { getLicense } from '@/License'; import { AuthenticatedRequest, LicenseRequest } from '@/requests'; diff --git a/packages/cli/src/workflows/workflows.controller.ee.ts b/packages/cli/src/workflows/workflows.controller.ee.ts index 0f6d924d31..04986499d4 100644 --- a/packages/cli/src/workflows/workflows.controller.ee.ts +++ b/packages/cli/src/workflows/workflows.controller.ee.ts @@ -10,7 +10,7 @@ import { validateEntity } from '@/GenericHelpers'; import type { WorkflowRequest } from '@/requests'; import { isSharingEnabled, rightDiff } from '@/UserManagement/UserManagementHelper'; import { EEWorkflowsService as EEWorkflows } from './workflows.services.ee'; -import { externalHooks } from '../Server'; +import { ExternalHooks } from '@/ExternalHooks'; import { SharedWorkflow } from '@db/entities/SharedWorkflow'; import { LoggerProxy } from 'n8n-workflow'; import * as TagHelpers from '@/TagHelpers'; @@ -117,7 +117,7 @@ EEWorkflowController.post( await validateEntity(newWorkflow); - await externalHooks.run('workflow.create', [newWorkflow]); + await ExternalHooks().run('workflow.create', [newWorkflow]); const { tags: tagIds } = req.body; @@ -178,7 +178,7 @@ EEWorkflowController.post( }); } - await externalHooks.run('workflow.afterCreate', [savedWorkflow]); + await ExternalHooks().run('workflow.afterCreate', [savedWorkflow]); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, newWorkflow, false); const { id, ...rest } = savedWorkflow; diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index b909135ce3..91871746d6 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -17,7 +17,7 @@ import { SharedWorkflow } from '@db/entities/SharedWorkflow'; import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { validateEntity } from '@/GenericHelpers'; import { InternalHooksManager } from '@/InternalHooksManager'; -import { externalHooks } from '@/Server'; +import { ExternalHooks } from '@/ExternalHooks'; import { getLogger } from '@/Logger'; import type { WorkflowRequest } from '@/requests'; import { isBelowOnboardingThreshold } from '@/WorkflowHelpers'; @@ -57,7 +57,7 @@ workflowsController.post( await validateEntity(newWorkflow); - await externalHooks.run('workflow.create', [newWorkflow]); + await ExternalHooks().run('workflow.create', [newWorkflow]); const { tags: tagIds } = req.body; @@ -103,7 +103,7 @@ workflowsController.post( }); } - await externalHooks.run('workflow.afterCreate', [savedWorkflow]); + await ExternalHooks().run('workflow.afterCreate', [savedWorkflow]); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, newWorkflow, false); const { id, ...rest } = savedWorkflow; @@ -273,7 +273,7 @@ workflowsController.delete( ResponseHelper.send(async (req: WorkflowRequest.Delete) => { const { id: workflowId } = req.params; - await externalHooks.run('workflow.delete', [workflowId]); + await ExternalHooks().run('workflow.delete', [workflowId]); const shared = await Db.collections.SharedWorkflow.findOne({ relations: ['workflow', 'role'], @@ -303,7 +303,7 @@ workflowsController.delete( await Db.collections.Workflow.delete(workflowId); void InternalHooksManager.getInstance().onWorkflowDeleted(req.user.id, workflowId, false); - await externalHooks.run('workflow.afterDelete', [workflowId]); + await ExternalHooks().run('workflow.afterDelete', [workflowId]); return true; }), diff --git a/packages/cli/src/workflows/workflows.services.ts b/packages/cli/src/workflows/workflows.services.ts index ffff2a3eb5..2c20aaaac9 100644 --- a/packages/cli/src/workflows/workflows.services.ts +++ b/packages/cli/src/workflows/workflows.services.ts @@ -13,7 +13,7 @@ import { SharedWorkflow } from '@db/entities/SharedWorkflow'; import { User } from '@db/entities/User'; import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { validateEntity } from '@/GenericHelpers'; -import { externalHooks } from '@/Server'; +import { ExternalHooks } from '@/ExternalHooks'; import * as TagHelpers from '@/TagHelpers'; import { WorkflowRequest } from '@/requests'; import { IWorkflowDb, IWorkflowExecutionDataProcess } from '@/Interfaces'; @@ -246,7 +246,7 @@ export class WorkflowsService { WorkflowHelpers.addNodeIds(workflow); - await externalHooks.run('workflow.update', [workflow]); + await ExternalHooks().run('workflow.update', [workflow]); if (shared.workflow.active) { // When workflow gets saved always remove it as the triggers could have been @@ -332,13 +332,13 @@ export class WorkflowsService { }); } - await externalHooks.run('workflow.afterUpdate', [updatedWorkflow]); + await ExternalHooks().run('workflow.afterUpdate', [updatedWorkflow]); void InternalHooksManager.getInstance().onWorkflowSaved(user.id, updatedWorkflow, false); if (updatedWorkflow.active) { // When the workflow is supposed to be active add it again try { - await externalHooks.run('workflow.activate', [updatedWorkflow]); + await ExternalHooks().run('workflow.activate', [updatedWorkflow]); await ActiveWorkflowRunner.getInstance().add( workflowId, shared.workflow.active ? 'update' : 'activate', diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 45afdfdc3c..e6cc59cd57 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -836,7 +836,7 @@ export async function getBinaryDataBuffer( propertyName: string, inputIndex: number, ): Promise { - const binaryData = inputData.main![inputIndex]![itemIndex]!.binary![propertyName]!; + const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!; return BinaryDataManager.getInstance().retrieveBinaryData(binaryData); } diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 351fae1e10..817395591c 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -876,8 +876,8 @@ export class WorkflowExecute { // The most nodes just have one but merge node for example has two and data // of both inputs has to be available to be able to process the node. if ( - executionData.data.main!.length < connectionIndex || - executionData.data.main![connectionIndex] === null + executionData.data.main.length < connectionIndex || + executionData.data.main[connectionIndex] === null ) { // Does not have the data of the connections so add back to stack this.runExecutionData.executionData!.nodeExecutionStack.push(executionData); diff --git a/packages/node-dev/src/Build.ts b/packages/node-dev/src/Build.ts index d52d339c48..c15affb5d1 100644 --- a/packages/node-dev/src/Build.ts +++ b/packages/node-dev/src/Build.ts @@ -8,7 +8,7 @@ import { file as tmpFile } from 'tmp-promise'; import { jsonParse } from 'n8n-workflow'; import { UserSettings } from 'n8n-core'; -import { IBuildOptions } from '.'; +import type { IBuildOptions } from './Interfaces'; /** * Create a custom tsconfig file as tsc currently has no way to define a base diff --git a/packages/node-dev/src/index.ts b/packages/node-dev/src/index.ts index bb4e283be6..6f0b3f63d7 100644 --- a/packages/node-dev/src/index.ts +++ b/packages/node-dev/src/index.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line import/no-cycle export * from './Build'; export * from './Create'; export * from './Interfaces'; diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts index 99e6995b01..a689c7bbf5 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts @@ -1,8 +1,8 @@ -import { INodeProperties } from 'n8n-workflow'; +import type { INodeProperties } from 'n8n-workflow'; -import { Operation, Resource } from '../types'; +import type { Operation, Resource, LanguageOptions } from '../types'; -export const languageOptions: INodeProperties['options'] = [ +export const languageOptions: LanguageOptions = [ { name: 'Danish', value: 'da', diff --git a/packages/nodes-base/nodes/ActionNetwork/types.d.ts b/packages/nodes-base/nodes/ActionNetwork/types.d.ts index 72e79cd5b9..a36033c3ea 100644 --- a/packages/nodes-base/nodes/ActionNetwork/types.d.ts +++ b/packages/nodes-base/nodes/ActionNetwork/types.d.ts @@ -1,4 +1,6 @@ -import { languageOptions } from './descriptions/SharedFields'; +import type { INodeProperties } from 'n8n-workflow'; + +export type LanguageOptions = INodeProperties['options']; export type Resource = | 'attendance' @@ -12,7 +14,7 @@ export type Resource = export type Operation = 'create' | 'delete' | 'get' | 'getAll' | 'update' | 'add' | 'remove'; // @ts-ignore -export type LanguageCodes = typeof languageOptions[number]['value']; +export type LanguageCodes = typeof LanguageOptions[number]['value']; // ---------------------------------------- // UI fields diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.utils.ts b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.utils.ts index e56666291b..a7e7f7b52a 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.utils.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.utils.ts @@ -6,7 +6,7 @@ import { INodePropertyOptions, NodeOperationError, } from 'n8n-workflow'; -import { GoogleSheet } from './GoogleSheet'; +import type { GoogleSheet } from './GoogleSheet'; import { RangeDetectionOptions, ResourceLocator, diff --git a/packages/nodes-base/nodes/SeaTable/Interfaces.ts b/packages/nodes-base/nodes/SeaTable/Interfaces.ts index 675be34d30..b2ec271b9c 100644 --- a/packages/nodes-base/nodes/SeaTable/Interfaces.ts +++ b/packages/nodes-base/nodes/SeaTable/Interfaces.ts @@ -1,4 +1,4 @@ -import { +import type { TColumnType, TColumnValue, TDtableMetadataColumns, diff --git a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts index ee670a8da7..729927ed0e 100644 --- a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts @@ -5,7 +5,7 @@ import { todoistApiRequest, todoistSyncRequest, } from '../GenericFunctions'; -import { Section, TodoistResponse } from './Service'; +import type { Section, TodoistResponse } from './Service'; import { v4 as uuid } from 'uuid'; export interface OperationHandler { diff --git a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts index 01ac5cdc60..179d615821 100644 --- a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts @@ -5,7 +5,7 @@ import { todoistApiRequest, todoistSyncRequest, } from '../GenericFunctions'; -import { Section, TodoistResponse } from './Service'; +import type { Section, TodoistResponse } from './Service'; import { v4 as uuid } from 'uuid'; export interface OperationHandler { diff --git a/packages/workflow/src/ExpressionError.ts b/packages/workflow/src/ExpressionError.ts index 2704a99a82..2fbd972bc9 100644 --- a/packages/workflow/src/ExpressionError.ts +++ b/packages/workflow/src/ExpressionError.ts @@ -1,4 +1,4 @@ -import { IDataObject } from './Interfaces'; +import type { IDataObject } from './Interfaces'; import { ExecutionBaseError } from './NodeErrors'; /** diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index e9ff0fb3af..c031f01bdf 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -10,7 +10,7 @@ import type { WorkflowHooks } from './WorkflowHooks'; import type { WorkflowActivationError } from './WorkflowActivationError'; import type { WorkflowOperationError } from './WorkflowErrors'; import type { NodeApiError, NodeOperationError } from './NodeErrors'; -import { ExpressionError } from './ExpressionError'; +import type { ExpressionError } from './ExpressionError'; export interface IAdditionalCredentialOptions { oauth2?: IOAuth2Options; diff --git a/packages/workflow/src/WorkflowDataProxy.ts b/packages/workflow/src/WorkflowDataProxy.ts index 30f56c6d03..fd28a3ef0d 100644 --- a/packages/workflow/src/WorkflowDataProxy.ts +++ b/packages/workflow/src/WorkflowDataProxy.ts @@ -501,7 +501,7 @@ export class WorkflowDataProxy { return undefined; } - const sourceData: ISourceData = that.executeData?.source.main![0] as ISourceData; + const sourceData: ISourceData = that.executeData.source.main[0] as ISourceData; if (name === 'name') { return sourceData.previousNode; @@ -993,7 +993,7 @@ export class WorkflowDataProxy { }); } - const sourceData: ISourceData = that.executeData?.source.main![ + const sourceData: ISourceData = that.executeData.source.main[ pairedItem.input || 0 ] as ISourceData; @@ -1105,7 +1105,7 @@ export class WorkflowDataProxy { }); } - const sourceData: ISourceData = that.executeData?.source.main![0] as ISourceData; + const sourceData: ISourceData = that.executeData.source.main[0] as ISourceData; if (property === 'context') { return that.nodeContextGetter(sourceData.previousNode);