refactor(core): Use IWorkflowBase over WorkflowEntity in most places (#13225)

This commit is contained in:
Tomi Turtiainen
2025-02-13 10:54:11 +02:00
committed by GitHub
parent 11cf1cd23a
commit f001edb2a2
54 changed files with 190 additions and 192 deletions

View File

@@ -1,9 +1,8 @@
import { Container } from '@n8n/di';
import type { AnnotationVote } from 'n8n-workflow';
import type { AnnotationVote, IWorkflowBase } from 'n8n-workflow';
import type { ExecutionData } from '@/databases/entities/execution-data';
import type { ExecutionEntity } from '@/databases/entities/execution-entity';
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
import { AnnotationTagRepository } from '@/databases/repositories/annotation-tag.repository.ee';
import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository';
import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository';
@@ -16,8 +15,8 @@ mockInstance(Telemetry);
export async function createManyExecutions(
amount: number,
workflow: WorkflowEntity,
callback: (workflow: WorkflowEntity) => Promise<ExecutionEntity>,
workflow: IWorkflowBase,
callback: (workflow: IWorkflowBase) => Promise<ExecutionEntity>,
) {
const executionsRequests = [...Array(amount)].map(async (_) => await callback(workflow));
return await Promise.all(executionsRequests);
@@ -31,7 +30,7 @@ export async function createExecution(
Omit<ExecutionEntity, 'metadata'> &
ExecutionData & { metadata: Array<{ key: string; value: string }> }
>,
workflow: WorkflowEntity,
workflow: IWorkflowBase,
) {
const { data, finished, mode, startedAt, stoppedAt, waitTill, status, deletedAt, metadata } =
attributes;
@@ -70,14 +69,14 @@ export async function createExecution(
/**
* Store a successful execution in the DB and assign it to a workflow.
*/
export async function createSuccessfulExecution(workflow: WorkflowEntity) {
export async function createSuccessfulExecution(workflow: IWorkflowBase) {
return await createExecution({ finished: true, status: 'success' }, workflow);
}
/**
* Store an error execution in the DB and assign it to a workflow.
*/
export async function createErrorExecution(workflow: WorkflowEntity) {
export async function createErrorExecution(workflow: IWorkflowBase) {
return await createExecution(
{ finished: false, stoppedAt: new Date(), status: 'error' },
workflow,
@@ -87,7 +86,7 @@ export async function createErrorExecution(workflow: WorkflowEntity) {
/**
* Store a waiting execution in the DB and assign it to a workflow.
*/
export async function createWaitingExecution(workflow: WorkflowEntity) {
export async function createWaitingExecution(workflow: IWorkflowBase) {
return await createExecution(
{ finished: false, waitTill: new Date(), status: 'waiting' },
workflow,