refactor(core): Abstract away duplication when finding first pinned trigger (no-changelog) (#5927)

This commit is contained in:
Michael Kret
2023-08-10 15:06:16 +03:00
committed by GitHub
parent 258e0ebb0f
commit 7f0db60f15
4 changed files with 66 additions and 16 deletions

View File

@@ -26,11 +26,13 @@ import type {
IWorkflowExecutionDataProcess,
} from '@/Interfaces';
import { NodeTypes } from '@/NodeTypes';
// eslint-disable-next-line import/no-cycle
import { WorkflowRunner } from '@/WorkflowRunner';
import config from '@/config';
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
import type { User } from '@db/entities/User';
import omit from 'lodash/omit';
// eslint-disable-next-line import/no-cycle
import { PermissionChecker } from './UserManagement/PermissionChecker';
import { isWorkflowIdValid } from './utils';
import { UserService } from './user/user.service';
@@ -575,6 +577,18 @@ export function validateWorkflowCredentialUsage(
return newWorkflowVersion;
}
export function getExecutionStartNode(data: IWorkflowExecutionDataProcess, workflow: Workflow) {
let startNode;
if (
data.startNodes?.length === 1 &&
Object.keys(data.pinData ?? {}).includes(data.startNodes[0])
) {
startNode = workflow.getNode(data.startNodes[0]) ?? undefined;
}
return startNode;
}
export async function getVariables(): Promise<IDataObject> {
const variables = await Container.get(VariablesService).getAllCached();
return Object.freeze(