mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Use IWorkflowBase over WorkflowEntity in most places (#13225)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user