refactor: Make execution IDs mandatory in BE (#8299)

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Omar Ajoue
2024-01-16 09:53:17 +00:00
committed by GitHub
parent 0f4f472a72
commit e1acb5911a
16 changed files with 136 additions and 136 deletions

View File

@@ -420,7 +420,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
// Workflow is saved so update in database
try {
await Container.get(WorkflowStaticDataService).saveStaticDataById(
this.workflowData.id as string,
this.workflowData.id,
newStaticData,
);
} catch (e) {
@@ -464,7 +464,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
this.retryOf,
);
await Container.get(ExecutionRepository).hardDelete({
workflowId: this.workflowData.id as string,
workflowId: this.workflowData.id,
executionId: this.executionId,
});
@@ -483,7 +483,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
await updateExistingExecution({
executionId: this.executionId,
workflowId: this.workflowData.id as string,
workflowId: this.workflowData.id,
executionData: fullExecutionData,
});
@@ -566,7 +566,7 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
// Workflow is saved so update in database
try {
await Container.get(WorkflowStaticDataService).saveStaticDataById(
this.workflowData.id as string,
this.workflowData.id,
newStaticData,
);
} catch (e) {
@@ -601,7 +601,7 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
await updateExistingExecution({
executionId: this.executionId,
workflowId: this.workflowData.id as string,
workflowId: this.workflowData.id,
executionData: fullExecutionData,
});
} catch (error) {
@@ -702,7 +702,7 @@ export async function getRunData(
export async function getWorkflowData(
workflowInfo: IExecuteWorkflowInfo,
parentWorkflowId?: string,
parentWorkflowId: string,
parentWorkflowSettings?: IWorkflowSettings,
): Promise<IWorkflowBase> {
if (workflowInfo.id === undefined && workflowInfo.code === undefined) {
@@ -748,7 +748,7 @@ async function executeWorkflow(
additionalData: IWorkflowExecuteAdditionalData,
options: {
node?: INode;
parentWorkflowId?: string;
parentWorkflowId: string;
inputData?: INodeExecutionData[];
parentExecutionId?: string;
loadedWorkflowData?: IWorkflowBase;
@@ -769,7 +769,7 @@ async function executeWorkflow(
const workflowName = workflowData ? workflowData.name : undefined;
const workflow = new Workflow({
id: workflowData.id?.toString(),
id: workflowData.id,
name: workflowName,
nodes: workflowData.nodes,
connections: workflowData.connections,
@@ -788,10 +788,7 @@ async function executeWorkflow(
if (options.parentExecutionId !== undefined) {
executionId = options.parentExecutionId;
} else {
executionId =
options.parentExecutionId !== undefined
? options.parentExecutionId
: await activeExecutions.add(runData);
executionId = options.parentExecutionId ?? (await activeExecutions.add(runData));
}
void internalHooks.onWorkflowBeforeExecute(executionId || '', runData);
@@ -801,7 +798,7 @@ async function executeWorkflow(
await PermissionChecker.check(workflow, additionalData.userId);
await PermissionChecker.checkSubworkflowExecutePolicy(
workflow,
options.parentWorkflowId!,
options.parentWorkflowId,
options.node,
);
@@ -879,6 +876,7 @@ async function executeWorkflow(
stoppedAt: fullRunData.stoppedAt,
status: fullRunData.status,
workflowData,
workflowId: workflowData.id,
};
if (workflowData.id) {
fullExecutionData.workflowId = workflowData.id;
@@ -1082,7 +1080,7 @@ export function getWorkflowHooksWorkerMain(
if (shouldNotSave) {
await Container.get(ExecutionRepository).hardDelete({
workflowId: this.workflowData.id as string,
workflowId: this.workflowData.id,
executionId: this.executionId,
});
}