mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
ci: Break most of the circular dependencies in code (no-changelog) (#4990)
This commit is contained in:
parent
82f763589b
commit
5db9c46043
|
@ -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<CredentialsEntity>(credential);
|
||||
|
@ -96,7 +96,7 @@ export async function saveCredential(
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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<ICredentialsDb | undefined> {
|
||||
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<void> {
|
||||
await externalHooks.run('credentials.delete', [credentials.id]);
|
||||
await ExternalHooks().run('credentials.delete', [credentials.id]);
|
||||
|
||||
await Db.collections.Credentials.remove(credentials);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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[];
|
||||
}
|
||||
|
|
|
@ -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[];
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
})
|
||||
|
|
|
@ -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',
|
||||
})
|
||||
|
|
|
@ -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[];
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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[];
|
||||
|
||||
|
|
|
@ -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',
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<string>;
|
||||
|
@ -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[] = [];
|
||||
|
||||
|
|
|
@ -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<number> {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}),
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -836,7 +836,7 @@ export async function getBinaryDataBuffer(
|
|||
propertyName: string,
|
||||
inputIndex: number,
|
||||
): Promise<Buffer> {
|
||||
const binaryData = inputData.main![inputIndex]![itemIndex]!.binary![propertyName]!;
|
||||
const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!;
|
||||
return BinaryDataManager.getInstance().retrieveBinaryData(binaryData);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// eslint-disable-next-line import/no-cycle
|
||||
export * from './Build';
|
||||
export * from './Create';
|
||||
export * from './Interfaces';
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
INodePropertyOptions,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { GoogleSheet } from './GoogleSheet';
|
||||
import type { GoogleSheet } from './GoogleSheet';
|
||||
import {
|
||||
RangeDetectionOptions,
|
||||
ResourceLocator,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {
|
||||
import type {
|
||||
TColumnType,
|
||||
TColumnValue,
|
||||
TDtableMetadataColumns,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IDataObject } from './Interfaces';
|
||||
import type { IDataObject } from './Interfaces';
|
||||
import { ExecutionBaseError } from './NodeErrors';
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue