ci: Break most of the circular dependencies in code (no-changelog) (#4990)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-12-21 10:46:26 +01:00 committed by GitHub
parent 82f763589b
commit 5db9c46043
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 105 additions and 110 deletions

View file

@ -10,7 +10,7 @@ import type { ICredentialsDb } from '@/Interfaces';
import { CredentialsEntity } from '@db/entities/CredentialsEntity'; import { CredentialsEntity } from '@db/entities/CredentialsEntity';
import { SharedCredentials } from '@db/entities/SharedCredentials'; import { SharedCredentials } from '@db/entities/SharedCredentials';
import { User } from '@db/entities/User'; import { User } from '@db/entities/User';
import { externalHooks } from '@/Server'; import { ExternalHooks } from '@/ExternalHooks';
import { IDependency, IJsonSchema } from '../../../types'; import { IDependency, IJsonSchema } from '../../../types';
import { CredentialRequest } from '@/requests'; import { CredentialRequest } from '@/requests';
@ -74,7 +74,7 @@ export async function saveCredential(
scope: 'credential', scope: 'credential',
}); });
await externalHooks.run('credentials.create', [encryptedData]); await ExternalHooks().run('credentials.create', [encryptedData]);
return Db.transaction(async (transactionManager) => { return Db.transaction(async (transactionManager) => {
const savedCredential = await transactionManager.save<CredentialsEntity>(credential); const savedCredential = await transactionManager.save<CredentialsEntity>(credential);
@ -96,7 +96,7 @@ export async function saveCredential(
} }
export async function removeCredential(credentials: CredentialsEntity): Promise<ICredentialsDb> { export async function removeCredential(credentials: CredentialsEntity): Promise<ICredentialsDb> {
await externalHooks.run('credentials.delete', [credentials.id]); await ExternalHooks().run('credentials.delete', [credentials.id]);
return Db.collections.Credentials.remove(credentials); return Db.collections.Credentials.remove(credentials);
} }

View file

@ -7,7 +7,7 @@ import * as ActiveWorkflowRunner from '@/ActiveWorkflowRunner';
import config from '@/config'; import config from '@/config';
import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { InternalHooksManager } from '@/InternalHooksManager'; import { InternalHooksManager } from '@/InternalHooksManager';
import { externalHooks } from '@/Server'; import { ExternalHooks } from '@/ExternalHooks';
import { addNodeIds, replaceInvalidCredentials } from '@/WorkflowHelpers'; import { addNodeIds, replaceInvalidCredentials } from '@/WorkflowHelpers';
import { WorkflowRequest } from '../../../types'; import { WorkflowRequest } from '../../../types';
import { authorize, validCursor } from '../../shared/middlewares/global.middleware'; import { authorize, validCursor } from '../../shared/middlewares/global.middleware';
@ -49,7 +49,7 @@ export = {
const createdWorkflow = await createWorkflow(workflow, req.user, role); 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); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, createdWorkflow, true);
return res.json(createdWorkflow); return res.json(createdWorkflow);
@ -76,7 +76,7 @@ export = {
await Db.collections.Workflow.delete(id); await Db.collections.Workflow.delete(id);
void InternalHooksManager.getInstance().onWorkflowDeleted(req.user.id, id.toString(), true); 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); return res.json(sharedWorkflow.workflow);
}, },
@ -219,7 +219,7 @@ export = {
const updatedWorkflow = await getWorkflowById(sharedWorkflow.workflowId); 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); void InternalHooksManager.getInstance().onWorkflowSaved(req.user.id, updateData, true);
return res.json(updatedWorkflow); return res.json(updatedWorkflow);

View file

@ -165,7 +165,7 @@ require('body-parser-xml')(bodyParser);
const exec = promisify(callbackExec); const exec = promisify(callbackExec);
export const externalHooks: IExternalHooksClass = ExternalHooks(); const externalHooks: IExternalHooksClass = ExternalHooks();
class App { class App {
app: express.Application; app: express.Application;

View file

@ -2,13 +2,13 @@ import { User } from '@/databases/entities/User';
import { whereClause } from '@/UserManagement/UserManagementHelper'; import { whereClause } from '@/UserManagement/UserManagementHelper';
import express from 'express'; import express from 'express';
import { LoggerProxy } from 'n8n-workflow'; import { LoggerProxy } from 'n8n-workflow';
import { import * as Db from '@/Db';
Db, import * as ResponseHelper from '@/ResponseHelper';
import type {
IWorkflowStatisticsCounts, IWorkflowStatisticsCounts,
IWorkflowStatisticsDataLoaded, IWorkflowStatisticsDataLoaded,
IWorkflowStatisticsTimestamps, IWorkflowStatisticsTimestamps,
ResponseHelper, } from '@/Interfaces';
} from '..';
import { StatisticsNames } from '../databases/entities/WorkflowStatistics'; import { StatisticsNames } from '../databases/entities/WorkflowStatistics';
import { getLogger } from '../Logger'; import { getLogger } from '../Logger';
import { ExecutionRequest } from '../requests'; import { ExecutionRequest } from '../requests';

View file

@ -20,7 +20,7 @@ import { CREDENTIAL_BLANKING_VALUE, RESPONSE_ERROR_MESSAGES } from '@/constants'
import { CredentialsEntity } from '@db/entities/CredentialsEntity'; import { CredentialsEntity } from '@db/entities/CredentialsEntity';
import { SharedCredentials } from '@db/entities/SharedCredentials'; import { SharedCredentials } from '@db/entities/SharedCredentials';
import { validateEntity } from '@/GenericHelpers'; import { validateEntity } from '@/GenericHelpers';
import { externalHooks } from '../Server'; import { ExternalHooks } from '@/ExternalHooks';
import type { User } from '@db/entities/User'; import type { User } from '@db/entities/User';
import type { CredentialRequest } from '@/requests'; import type { CredentialRequest } from '@/requests';
@ -234,7 +234,7 @@ export class CredentialsService {
credentialId: string, credentialId: string,
newCredentialData: ICredentialsDb, newCredentialData: ICredentialsDb,
): Promise<ICredentialsDb | undefined> { ): Promise<ICredentialsDb | undefined> {
await externalHooks.run('credentials.update', [newCredentialData]); await ExternalHooks().run('credentials.update', [newCredentialData]);
// Update the credentials in DB // Update the credentials in DB
await Db.collections.Credentials.update(credentialId, newCredentialData); await Db.collections.Credentials.update(credentialId, newCredentialData);
@ -253,7 +253,7 @@ export class CredentialsService {
const newCredential = new CredentialsEntity(); const newCredential = new CredentialsEntity();
Object.assign(newCredential, credential, encryptedData); Object.assign(newCredential, credential, encryptedData);
await externalHooks.run('credentials.create', [encryptedData]); await ExternalHooks().run('credentials.create', [encryptedData]);
const role = await Db.collections.Role.findOneOrFail({ const role = await Db.collections.Role.findOneOrFail({
name: 'owner', name: 'owner',
@ -285,7 +285,7 @@ export class CredentialsService {
} }
static async delete(credentials: CredentialsEntity): Promise<void> { static async delete(credentials: CredentialsEntity): Promise<void> {
await externalHooks.run('credentials.delete', [credentials.id]); await ExternalHooks().run('credentials.delete', [credentials.id]);
await Db.collections.Credentials.remove(credentials); await Db.collections.Credentials.remove(credentials);
} }

View file

@ -27,7 +27,7 @@ import {
} from '@/CredentialsHelper'; } from '@/CredentialsHelper';
import { getLogger } from '@/Logger'; import { getLogger } from '@/Logger';
import { OAuthRequest } from '@/requests'; import { OAuthRequest } from '@/requests';
import { externalHooks } from '@/Server'; import { ExternalHooks } from '@/ExternalHooks';
import config from '@/config'; import config from '@/config';
import { getInstanceBaseUrl } from '@/UserManagement/UserManagementHelper'; import { getInstanceBaseUrl } from '@/UserManagement/UserManagementHelper';
@ -129,7 +129,7 @@ oauth2CredentialController.get(
state: stateEncodedStr, state: stateEncodedStr,
}; };
await externalHooks.run('oauth2.authenticate', [oAuthOptions]); await ExternalHooks().run('oauth2.authenticate', [oAuthOptions]);
const oAuthObj = new ClientOAuth2(oAuthOptions); const oAuthObj = new ClientOAuth2(oAuthOptions);
@ -281,7 +281,7 @@ oauth2CredentialController.get(
delete oAuth2Parameters.clientSecret; delete oAuth2Parameters.clientSecret;
} }
await externalHooks.run('oauth2.callback', [oAuth2Parameters]); await ExternalHooks().run('oauth2.callback', [oAuth2Parameters]);
const oAuthObj = new ClientOAuth2(oAuth2Parameters); const oAuthObj = new ClientOAuth2(oAuth2Parameters);

View file

@ -1,7 +1,7 @@
import type { ICredentialNodeAccess } from 'n8n-workflow'; import type { ICredentialNodeAccess } from 'n8n-workflow';
import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { IsArray, IsObject, IsString, Length } from 'class-validator'; import { IsArray, IsObject, IsString, Length } from 'class-validator';
import { SharedCredentials } from './SharedCredentials'; import type { SharedCredentials } from './SharedCredentials';
import { AbstractEntity, jsonColumnType } from './AbstractEntity'; import { AbstractEntity, jsonColumnType } from './AbstractEntity';
import type { ICredentialsDb } from '@/Interfaces'; import type { ICredentialsDb } from '@/Interfaces';
@ -28,7 +28,7 @@ export class CredentialsEntity extends AbstractEntity implements ICredentialsDb
}) })
type: string; type: string;
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.credentials) @OneToMany('SharedCredentials', 'credentials')
shared: SharedCredentials[]; shared: SharedCredentials[];
@Column(jsonColumnType) @Column(jsonColumnType)

View file

@ -1,5 +1,5 @@
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'; import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
import { InstalledPackages } from './InstalledPackages'; import type { InstalledPackages } from './InstalledPackages';
@Entity() @Entity()
export class InstalledNodes { export class InstalledNodes {
@ -12,10 +12,7 @@ export class InstalledNodes {
@Column() @Column()
latestVersion: string; latestVersion: string;
@ManyToOne( @ManyToOne('InstalledPackages', 'installedNodes')
() => InstalledPackages,
(installedPackages: InstalledPackages) => installedPackages.installedNodes,
)
@JoinColumn({ name: 'package', referencedColumnName: 'packageName' }) @JoinColumn({ name: 'package', referencedColumnName: 'packageName' })
package: InstalledPackages; package: InstalledPackages;
} }

View file

@ -1,5 +1,5 @@
import { Column, Entity, JoinColumn, OneToMany, PrimaryColumn } from 'typeorm'; import { Column, Entity, JoinColumn, OneToMany, PrimaryColumn } from 'typeorm';
import { InstalledNodes } from './InstalledNodes'; import type { InstalledNodes } from './InstalledNodes';
import { AbstractEntity } from './AbstractEntity'; import { AbstractEntity } from './AbstractEntity';
@Entity() @Entity()
@ -16,7 +16,7 @@ export class InstalledPackages extends AbstractEntity {
@Column() @Column()
authorEmail?: string; authorEmail?: string;
@OneToMany(() => InstalledNodes, (installedNode) => installedNode.package) @OneToMany('InstalledNodes', 'package')
@JoinColumn({ referencedColumnName: 'package' }) @JoinColumn({ referencedColumnName: 'package' })
installedNodes: InstalledNodes[]; installedNodes: InstalledNodes[];
} }

View file

@ -1,9 +1,9 @@
import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm'; import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';
import { IsString, Length } from 'class-validator'; import { IsString, Length } from 'class-validator';
import { User } from './User'; import type { User } from './User';
import { SharedWorkflow } from './SharedWorkflow'; import type { SharedWorkflow } from './SharedWorkflow';
import { SharedCredentials } from './SharedCredentials'; import type { SharedCredentials } from './SharedCredentials';
import { AbstractEntity } from './AbstractEntity'; import { AbstractEntity } from './AbstractEntity';
export type RoleNames = 'owner' | 'member' | 'user' | 'editor'; export type RoleNames = 'owner' | 'member' | 'user' | 'editor';
@ -23,12 +23,12 @@ export class Role extends AbstractEntity {
@Column() @Column()
scope: RoleScopes; scope: RoleScopes;
@OneToMany(() => User, (user) => user.globalRole) @OneToMany('User', 'globalRole')
globalForUsers: User[]; globalForUsers: User[];
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.role) @OneToMany('SharedWorkflow', 'role')
sharedWorkflows: SharedWorkflow[]; sharedWorkflows: SharedWorkflow[];
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.role) @OneToMany('SharedCredentials', 'role')
sharedCredentials: SharedCredentials[]; sharedCredentials: SharedCredentials[];
} }

View file

@ -1,21 +1,21 @@
import { Entity, ManyToOne, RelationId } from 'typeorm'; import { Entity, ManyToOne, RelationId } from 'typeorm';
import { CredentialsEntity } from './CredentialsEntity'; import type { CredentialsEntity } from './CredentialsEntity';
import { User } from './User'; import type { User } from './User';
import { Role } from './Role'; import type { Role } from './Role';
import { AbstractEntity } from './AbstractEntity'; import { AbstractEntity } from './AbstractEntity';
@Entity() @Entity()
export class SharedCredentials extends AbstractEntity { export class SharedCredentials extends AbstractEntity {
@ManyToOne(() => Role, (role) => role.sharedCredentials, { nullable: false }) @ManyToOne('Role', 'sharedCredentials', { nullable: false })
role: Role; role: Role;
@ManyToOne(() => User, (user) => user.sharedCredentials, { primary: true }) @ManyToOne('User', 'sharedCredentials', { primary: true })
user: User; user: User;
@RelationId((sharedCredential: SharedCredentials) => sharedCredential.user) @RelationId((sharedCredential: SharedCredentials) => sharedCredential.user)
userId: string; userId: string;
@ManyToOne(() => CredentialsEntity, (credentials) => credentials.shared, { @ManyToOne('CredentialsEntity', 'shared', {
primary: true, primary: true,
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })

View file

@ -1,21 +1,21 @@
import { Entity, ManyToOne, RelationId } from 'typeorm'; import { Entity, ManyToOne, RelationId } from 'typeorm';
import { WorkflowEntity } from './WorkflowEntity'; import type { WorkflowEntity } from './WorkflowEntity';
import { User } from './User'; import type { User } from './User';
import { Role } from './Role'; import type { Role } from './Role';
import { AbstractEntity } from './AbstractEntity'; import { AbstractEntity } from './AbstractEntity';
@Entity() @Entity()
export class SharedWorkflow extends AbstractEntity { export class SharedWorkflow extends AbstractEntity {
@ManyToOne(() => Role, (role) => role.sharedWorkflows, { nullable: false }) @ManyToOne('Role', 'sharedWorkflows', { nullable: false })
role: Role; role: Role;
@ManyToOne(() => User, (user) => user.sharedWorkflows, { primary: true }) @ManyToOne('User', 'sharedWorkflows', { primary: true })
user: User; user: User;
@RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user) @RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user)
userId: string; userId: string;
@ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, { @ManyToOne('WorkflowEntity', 'shared', {
primary: true, primary: true,
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })

View file

@ -1,9 +1,9 @@
import { Column, Entity, Generated, Index, ManyToMany, PrimaryColumn } from 'typeorm'; import { Column, Entity, Generated, Index, ManyToMany, PrimaryColumn } from 'typeorm';
import { IsString, Length } from 'class-validator'; import { IsString, Length } from 'class-validator';
import { ITagDb } from '@/Interfaces'; import type { ITagDb } from '@/Interfaces';
import { idStringifier } from '../utils/transformers'; import { idStringifier } from '../utils/transformers';
import { WorkflowEntity } from './WorkflowEntity'; import type { WorkflowEntity } from './WorkflowEntity';
import { AbstractEntity } from './AbstractEntity'; import { AbstractEntity } from './AbstractEntity';
@Entity() @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.' }) @Length(1, 24, { message: 'Tag name must be $constraint1 to $constraint2 characters long.' })
name: string; name: string;
@ManyToMany(() => WorkflowEntity, (workflow) => workflow.tags) @ManyToMany('WorkflowEntity', 'tags')
workflows: WorkflowEntity[]; workflows: WorkflowEntity[];
} }

View file

@ -12,9 +12,9 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsEmail, IsString, Length } from 'class-validator'; import { IsEmail, IsString, Length } from 'class-validator';
import type { IUser } from 'n8n-workflow'; import type { IUser } from 'n8n-workflow';
import { Role } from './Role'; import type { Role } from './Role';
import { SharedWorkflow } from './SharedWorkflow'; import type { SharedWorkflow } from './SharedWorkflow';
import { SharedCredentials } from './SharedCredentials'; import type { SharedCredentials } from './SharedCredentials';
import { NoXss } from '../utils/customValidators'; import { NoXss } from '../utils/customValidators';
import { objectRetriever, lowerCaser } from '../utils/transformers'; import { objectRetriever, lowerCaser } from '../utils/transformers';
import { AbstractEntity, jsonColumnType } from './AbstractEntity'; import { AbstractEntity, jsonColumnType } from './AbstractEntity';
@ -74,16 +74,16 @@ export class User extends AbstractEntity implements IUser {
}) })
settings: IUserSettings | null; settings: IUserSettings | null;
@ManyToOne(() => Role, (role) => role.globalForUsers, { @ManyToOne('Role', 'globalForUsers', {
cascade: true, cascade: true,
nullable: false, nullable: false,
}) })
globalRole: Role; globalRole: Role;
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.user) @OneToMany('SharedWorkflow', 'user')
sharedWorkflows: SharedWorkflow[]; sharedWorkflows: SharedWorkflow[];
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.user) @OneToMany('SharedCredentials', 'user')
sharedCredentials: SharedCredentials[]; sharedCredentials: SharedCredentials[];
@BeforeInsert() @BeforeInsert()

View file

@ -21,11 +21,11 @@ import {
} from 'typeorm'; } from 'typeorm';
import config from '@/config'; import config from '@/config';
import { TagEntity } from './TagEntity'; import type { TagEntity } from './TagEntity';
import { SharedWorkflow } from './SharedWorkflow'; import type { SharedWorkflow } from './SharedWorkflow';
import type { WorkflowStatistics } from './WorkflowStatistics';
import { objectRetriever, sqlite } from '../utils/transformers'; import { objectRetriever, sqlite } from '../utils/transformers';
import { AbstractEntity, jsonColumnType } from './AbstractEntity'; import { AbstractEntity, jsonColumnType } from './AbstractEntity';
import { WorkflowStatistics } from './WorkflowStatistics';
import type { IWorkflowDb } from '@/Interfaces'; import type { IWorkflowDb } from '@/Interfaces';
@Entity() @Entity()
@ -63,7 +63,7 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
}) })
staticData?: IDataObject; staticData?: IDataObject;
@ManyToMany(() => TagEntity, (tag) => tag.workflows) @ManyToMany('TagEntity', 'workflows')
@JoinTable({ @JoinTable({
name: 'workflows_tags', // table name for the junction table of this relation name: 'workflows_tags', // table name for the junction table of this relation
joinColumn: { joinColumn: {
@ -77,13 +77,10 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
}) })
tags?: TagEntity[]; tags?: TagEntity[];
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow) @OneToMany('SharedWorkflow', 'workflow')
shared: SharedWorkflow[]; shared: SharedWorkflow[];
@OneToMany( @OneToMany('WorkflowStatistics', 'workflow')
() => WorkflowStatistics,
(workflowStatistics: WorkflowStatistics) => workflowStatistics.workflow,
)
@JoinColumn({ referencedColumnName: 'workflow' }) @JoinColumn({ referencedColumnName: 'workflow' })
statistics: WorkflowStatistics[]; statistics: WorkflowStatistics[];

View file

@ -1,6 +1,6 @@
import { Column, Entity, RelationId, ManyToOne, PrimaryColumn } from 'typeorm'; import { Column, Entity, RelationId, ManyToOne, PrimaryColumn } from 'typeorm';
import { datetimeColumnType } from './AbstractEntity'; import { datetimeColumnType } from './AbstractEntity';
import { WorkflowEntity } from './WorkflowEntity'; import type { WorkflowEntity } from './WorkflowEntity';
export enum StatisticsNames { export enum StatisticsNames {
productionSuccess = 'production_success', productionSuccess = 'production_success',
@ -20,7 +20,7 @@ export class WorkflowStatistics {
@PrimaryColumn({ length: 128 }) @PrimaryColumn({ length: 128 })
name: StatisticsNames; name: StatisticsNames;
@ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, { @ManyToOne('WorkflowEntity', 'shared', {
primary: true, primary: true,
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })

View file

@ -1,7 +1,8 @@
import { INode, IRun, IWorkflowBase, LoggerProxy } from 'n8n-workflow'; import { INode, IRun, IWorkflowBase, LoggerProxy } from 'n8n-workflow';
import { Db, InternalHooksManager } from '..'; import * as Db from '@/Db';
import { StatisticsNames } from '../databases/entities/WorkflowStatistics'; import { InternalHooksManager } from '@/InternalHooksManager';
import { getWorkflowOwner } from '../UserManagement/UserManagementHelper'; import { StatisticsNames } from '@/databases/entities/WorkflowStatistics';
import { getWorkflowOwner } from '@/UserManagement/UserManagementHelper';
export async function workflowExecutionCompleted( export async function workflowExecutionCompleted(
workflowData: IWorkflowBase, workflowData: IWorkflowBase,

View file

@ -8,7 +8,6 @@ import { FindOperator, In, IsNull, LessThanOrEqual, Not, Raw } from 'typeorm';
import * as ActiveExecutions from '@/ActiveExecutions'; import * as ActiveExecutions from '@/ActiveExecutions';
import config from '@/config'; import config from '@/config';
import { User } from '@/databases/entities/User'; import { User } from '@/databases/entities/User';
import { DEFAULT_EXECUTIONS_GET_ALL_LIMIT } from '@/GenericHelpers';
import { import {
IExecutionFlattedResponse, IExecutionFlattedResponse,
IExecutionResponse, IExecutionResponse,
@ -22,7 +21,9 @@ import type { ExecutionRequest } from '@/requests';
import * as ResponseHelper from '@/ResponseHelper'; import * as ResponseHelper from '@/ResponseHelper';
import { getSharedWorkflowIds } from '@/WorkflowHelpers'; import { getSharedWorkflowIds } from '@/WorkflowHelpers';
import { WorkflowRunner } from '@/WorkflowRunner'; 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 { interface IGetExecutionsQueryFilter {
id?: FindOperator<string>; id?: FindOperator<string>;
@ -174,7 +175,7 @@ export class ExecutionsService {
const limit = req.query.limit const limit = req.query.limit
? parseInt(req.query.limit, 10) ? parseInt(req.query.limit, 10)
: DEFAULT_EXECUTIONS_GET_ALL_LIMIT; : GenericHelpers.DEFAULT_EXECUTIONS_GET_ALL_LIMIT;
const executingWorkflowIds: string[] = []; const executingWorkflowIds: string[] = [];

View file

@ -1,5 +1,6 @@
import { getLicense } from '@/License'; import { getLicense } from '@/License';
import { Db, ILicenseReadResponse } from '..'; import type { ILicenseReadResponse } from '@/Interfaces';
import * as Db from '@/Db';
export class LicenseService { export class LicenseService {
static async getActiveTriggerCount(): Promise<number> { static async getActiveTriggerCount(): Promise<number> {

View file

@ -4,12 +4,9 @@ import express from 'express';
import { LoggerProxy } from 'n8n-workflow'; import { LoggerProxy } from 'n8n-workflow';
import { getLogger } from '@/Logger'; import { getLogger } from '@/Logger';
import { import * as ResponseHelper from '@/ResponseHelper';
ILicensePostResponse, import { InternalHooksManager } from '@/InternalHooksManager';
ILicenseReadResponse, import type { ILicensePostResponse, ILicenseReadResponse } from '@/Interfaces';
InternalHooksManager,
ResponseHelper,
} from '..';
import { LicenseService } from './License.service'; import { LicenseService } from './License.service';
import { getLicense } from '@/License'; import { getLicense } from '@/License';
import { AuthenticatedRequest, LicenseRequest } from '@/requests'; import { AuthenticatedRequest, LicenseRequest } from '@/requests';

View file

@ -10,7 +10,7 @@ import { validateEntity } from '@/GenericHelpers';
import type { WorkflowRequest } from '@/requests'; import type { WorkflowRequest } from '@/requests';
import { isSharingEnabled, rightDiff } from '@/UserManagement/UserManagementHelper'; import { isSharingEnabled, rightDiff } from '@/UserManagement/UserManagementHelper';
import { EEWorkflowsService as EEWorkflows } from './workflows.services.ee'; import { EEWorkflowsService as EEWorkflows } from './workflows.services.ee';
import { externalHooks } from '../Server'; import { ExternalHooks } from '@/ExternalHooks';
import { SharedWorkflow } from '@db/entities/SharedWorkflow'; import { SharedWorkflow } from '@db/entities/SharedWorkflow';
import { LoggerProxy } from 'n8n-workflow'; import { LoggerProxy } from 'n8n-workflow';
import * as TagHelpers from '@/TagHelpers'; import * as TagHelpers from '@/TagHelpers';
@ -117,7 +117,7 @@ EEWorkflowController.post(
await validateEntity(newWorkflow); await validateEntity(newWorkflow);
await externalHooks.run('workflow.create', [newWorkflow]); await ExternalHooks().run('workflow.create', [newWorkflow]);
const { tags: tagIds } = req.body; 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); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, newWorkflow, false);
const { id, ...rest } = savedWorkflow; const { id, ...rest } = savedWorkflow;

View file

@ -17,7 +17,7 @@ import { SharedWorkflow } from '@db/entities/SharedWorkflow';
import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { validateEntity } from '@/GenericHelpers'; import { validateEntity } from '@/GenericHelpers';
import { InternalHooksManager } from '@/InternalHooksManager'; import { InternalHooksManager } from '@/InternalHooksManager';
import { externalHooks } from '@/Server'; import { ExternalHooks } from '@/ExternalHooks';
import { getLogger } from '@/Logger'; import { getLogger } from '@/Logger';
import type { WorkflowRequest } from '@/requests'; import type { WorkflowRequest } from '@/requests';
import { isBelowOnboardingThreshold } from '@/WorkflowHelpers'; import { isBelowOnboardingThreshold } from '@/WorkflowHelpers';
@ -57,7 +57,7 @@ workflowsController.post(
await validateEntity(newWorkflow); await validateEntity(newWorkflow);
await externalHooks.run('workflow.create', [newWorkflow]); await ExternalHooks().run('workflow.create', [newWorkflow]);
const { tags: tagIds } = req.body; 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); void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, newWorkflow, false);
const { id, ...rest } = savedWorkflow; const { id, ...rest } = savedWorkflow;
@ -273,7 +273,7 @@ workflowsController.delete(
ResponseHelper.send(async (req: WorkflowRequest.Delete) => { ResponseHelper.send(async (req: WorkflowRequest.Delete) => {
const { id: workflowId } = req.params; const { id: workflowId } = req.params;
await externalHooks.run('workflow.delete', [workflowId]); await ExternalHooks().run('workflow.delete', [workflowId]);
const shared = await Db.collections.SharedWorkflow.findOne({ const shared = await Db.collections.SharedWorkflow.findOne({
relations: ['workflow', 'role'], relations: ['workflow', 'role'],
@ -303,7 +303,7 @@ workflowsController.delete(
await Db.collections.Workflow.delete(workflowId); await Db.collections.Workflow.delete(workflowId);
void InternalHooksManager.getInstance().onWorkflowDeleted(req.user.id, workflowId, false); void InternalHooksManager.getInstance().onWorkflowDeleted(req.user.id, workflowId, false);
await externalHooks.run('workflow.afterDelete', [workflowId]); await ExternalHooks().run('workflow.afterDelete', [workflowId]);
return true; return true;
}), }),

View file

@ -13,7 +13,7 @@ import { SharedWorkflow } from '@db/entities/SharedWorkflow';
import { User } from '@db/entities/User'; import { User } from '@db/entities/User';
import { WorkflowEntity } from '@db/entities/WorkflowEntity'; import { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { validateEntity } from '@/GenericHelpers'; import { validateEntity } from '@/GenericHelpers';
import { externalHooks } from '@/Server'; import { ExternalHooks } from '@/ExternalHooks';
import * as TagHelpers from '@/TagHelpers'; import * as TagHelpers from '@/TagHelpers';
import { WorkflowRequest } from '@/requests'; import { WorkflowRequest } from '@/requests';
import { IWorkflowDb, IWorkflowExecutionDataProcess } from '@/Interfaces'; import { IWorkflowDb, IWorkflowExecutionDataProcess } from '@/Interfaces';
@ -246,7 +246,7 @@ export class WorkflowsService {
WorkflowHelpers.addNodeIds(workflow); WorkflowHelpers.addNodeIds(workflow);
await externalHooks.run('workflow.update', [workflow]); await ExternalHooks().run('workflow.update', [workflow]);
if (shared.workflow.active) { if (shared.workflow.active) {
// When workflow gets saved always remove it as the triggers could have been // 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); void InternalHooksManager.getInstance().onWorkflowSaved(user.id, updatedWorkflow, false);
if (updatedWorkflow.active) { if (updatedWorkflow.active) {
// When the workflow is supposed to be active add it again // When the workflow is supposed to be active add it again
try { try {
await externalHooks.run('workflow.activate', [updatedWorkflow]); await ExternalHooks().run('workflow.activate', [updatedWorkflow]);
await ActiveWorkflowRunner.getInstance().add( await ActiveWorkflowRunner.getInstance().add(
workflowId, workflowId,
shared.workflow.active ? 'update' : 'activate', shared.workflow.active ? 'update' : 'activate',

View file

@ -836,7 +836,7 @@ export async function getBinaryDataBuffer(
propertyName: string, propertyName: string,
inputIndex: number, inputIndex: number,
): Promise<Buffer> { ): Promise<Buffer> {
const binaryData = inputData.main![inputIndex]![itemIndex]!.binary![propertyName]!; const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!;
return BinaryDataManager.getInstance().retrieveBinaryData(binaryData); return BinaryDataManager.getInstance().retrieveBinaryData(binaryData);
} }

View file

@ -876,8 +876,8 @@ export class WorkflowExecute {
// The most nodes just have one but merge node for example has two and data // 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. // of both inputs has to be available to be able to process the node.
if ( if (
executionData.data.main!.length < connectionIndex || executionData.data.main.length < connectionIndex ||
executionData.data.main![connectionIndex] === null executionData.data.main[connectionIndex] === null
) { ) {
// Does not have the data of the connections so add back to stack // Does not have the data of the connections so add back to stack
this.runExecutionData.executionData!.nodeExecutionStack.push(executionData); this.runExecutionData.executionData!.nodeExecutionStack.push(executionData);

View file

@ -8,7 +8,7 @@ import { file as tmpFile } from 'tmp-promise';
import { jsonParse } from 'n8n-workflow'; import { jsonParse } from 'n8n-workflow';
import { UserSettings } from 'n8n-core'; 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 * Create a custom tsconfig file as tsc currently has no way to define a base

View file

@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-cycle
export * from './Build'; export * from './Build';
export * from './Create'; export * from './Create';
export * from './Interfaces'; export * from './Interfaces';

View file

@ -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', name: 'Danish',
value: 'da', value: 'da',

View file

@ -1,4 +1,6 @@
import { languageOptions } from './descriptions/SharedFields'; import type { INodeProperties } from 'n8n-workflow';
export type LanguageOptions = INodeProperties['options'];
export type Resource = export type Resource =
| 'attendance' | 'attendance'
@ -12,7 +14,7 @@ export type Resource =
export type Operation = 'create' | 'delete' | 'get' | 'getAll' | 'update' | 'add' | 'remove'; export type Operation = 'create' | 'delete' | 'get' | 'getAll' | 'update' | 'add' | 'remove';
// @ts-ignore // @ts-ignore
export type LanguageCodes = typeof languageOptions[number]['value']; export type LanguageCodes = typeof LanguageOptions[number]['value'];
// ---------------------------------------- // ----------------------------------------
// UI fields // UI fields

View file

@ -6,7 +6,7 @@ import {
INodePropertyOptions, INodePropertyOptions,
NodeOperationError, NodeOperationError,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { GoogleSheet } from './GoogleSheet'; import type { GoogleSheet } from './GoogleSheet';
import { import {
RangeDetectionOptions, RangeDetectionOptions,
ResourceLocator, ResourceLocator,

View file

@ -1,4 +1,4 @@
import { import type {
TColumnType, TColumnType,
TColumnValue, TColumnValue,
TDtableMetadataColumns, TDtableMetadataColumns,

View file

@ -5,7 +5,7 @@ import {
todoistApiRequest, todoistApiRequest,
todoistSyncRequest, todoistSyncRequest,
} from '../GenericFunctions'; } from '../GenericFunctions';
import { Section, TodoistResponse } from './Service'; import type { Section, TodoistResponse } from './Service';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
export interface OperationHandler { export interface OperationHandler {

View file

@ -5,7 +5,7 @@ import {
todoistApiRequest, todoistApiRequest,
todoistSyncRequest, todoistSyncRequest,
} from '../GenericFunctions'; } from '../GenericFunctions';
import { Section, TodoistResponse } from './Service'; import type { Section, TodoistResponse } from './Service';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
export interface OperationHandler { export interface OperationHandler {

View file

@ -1,4 +1,4 @@
import { IDataObject } from './Interfaces'; import type { IDataObject } from './Interfaces';
import { ExecutionBaseError } from './NodeErrors'; import { ExecutionBaseError } from './NodeErrors';
/** /**

View file

@ -10,7 +10,7 @@ import type { WorkflowHooks } from './WorkflowHooks';
import type { WorkflowActivationError } from './WorkflowActivationError'; import type { WorkflowActivationError } from './WorkflowActivationError';
import type { WorkflowOperationError } from './WorkflowErrors'; import type { WorkflowOperationError } from './WorkflowErrors';
import type { NodeApiError, NodeOperationError } from './NodeErrors'; import type { NodeApiError, NodeOperationError } from './NodeErrors';
import { ExpressionError } from './ExpressionError'; import type { ExpressionError } from './ExpressionError';
export interface IAdditionalCredentialOptions { export interface IAdditionalCredentialOptions {
oauth2?: IOAuth2Options; oauth2?: IOAuth2Options;

View file

@ -501,7 +501,7 @@ export class WorkflowDataProxy {
return undefined; 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') { if (name === 'name') {
return sourceData.previousNode; 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 pairedItem.input || 0
] as ISourceData; ] 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') { if (property === 'context') {
return that.nodeContextGetter(sourceData.previousNode); return that.nodeContextGetter(sourceData.previousNode);