refactor(core): Make workflow services injectable (no-changelog) (#8033)
Refactor static workflow service classes into DI-compatible classes Context: https://n8nio.slack.com/archives/C069HS026UF/p1702466571648889 Up next: - Inject dependencies into workflow services - Consolidate workflow controllers into one - Make workflow controller injectable - Inject dependencies into workflow controller --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -3,8 +3,9 @@ import { getSharedWorkflowIds } from '@/WorkflowHelpers';
|
||||
import { ExecutionsService } from './executions.service';
|
||||
import type { ExecutionRequest } from '@/requests';
|
||||
import type { IExecutionResponse, IExecutionFlattedResponse } from '@/Interfaces';
|
||||
import { EEWorkflowsService as EEWorkflows } from '../workflows/workflows.services.ee';
|
||||
import { EnterpriseWorkflowService } from '../workflows/workflow.service.ee';
|
||||
import type { WorkflowWithSharingsAndCredentials } from '@/workflows/workflows.types';
|
||||
import Container from 'typedi';
|
||||
|
||||
export class EEExecutionsService extends ExecutionsService {
|
||||
/**
|
||||
@@ -23,14 +24,16 @@ export class EEExecutionsService extends ExecutionsService {
|
||||
if (!execution) return;
|
||||
|
||||
const relations = ['shared', 'shared.user', 'shared.role'];
|
||||
const workflow = (await EEWorkflows.get(
|
||||
const enterpriseWorkflowService = Container.get(EnterpriseWorkflowService);
|
||||
|
||||
const workflow = (await enterpriseWorkflowService.get(
|
||||
{ id: execution.workflowId },
|
||||
{ relations },
|
||||
)) as WorkflowWithSharingsAndCredentials;
|
||||
if (!workflow) return;
|
||||
|
||||
EEWorkflows.addOwnerAndSharings(workflow);
|
||||
await EEWorkflows.addCredentialsToWorkflow(workflow, req.user);
|
||||
enterpriseWorkflowService.addOwnerAndSharings(workflow);
|
||||
await enterpriseWorkflowService.addCredentialsToWorkflow(workflow, req.user);
|
||||
|
||||
execution.workflowData = {
|
||||
...execution.workflowData,
|
||||
|
||||
Reference in New Issue
Block a user