File size: 1,653 Bytes
aec3094 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import type { WorkflowWithSharingsAndCredentials, IExecutionResponse } from '@n8n/db';
import { WorkflowRepository } from '@n8n/db';
import { Service } from '@n8n/di';
import type { IExecutionFlattedResponse } from '@/interfaces';
import { ExecutionService } from './execution.service';
import type { ExecutionRequest } from './execution.types';
import { EnterpriseWorkflowService } from '../workflows/workflow.service.ee';
@Service()
export class EnterpriseExecutionsService {
constructor(
private readonly executionService: ExecutionService,
private readonly workflowRepository: WorkflowRepository,
private readonly enterpriseWorkflowService: EnterpriseWorkflowService,
) {}
async findOne(
req: ExecutionRequest.GetOne,
sharedWorkflowIds: string[],
): Promise<IExecutionResponse | IExecutionFlattedResponse | undefined> {
const execution = await this.executionService.findOne(req, sharedWorkflowIds);
if (!execution) return;
const workflow = (await this.workflowRepository.get({
id: execution.workflowId,
})) as WorkflowWithSharingsAndCredentials;
if (!workflow) return;
const workflowWithSharingsMetaData =
this.enterpriseWorkflowService.addOwnerAndSharings(workflow);
await this.enterpriseWorkflowService.addCredentialsToWorkflow(
workflowWithSharingsMetaData,
req.user,
);
execution.workflowData = {
...execution.workflowData,
homeProject: workflowWithSharingsMetaData.homeProject,
sharedWithProjects: workflowWithSharingsMetaData.sharedWithProjects,
usedCredentials: workflowWithSharingsMetaData.usedCredentials,
} as WorkflowWithSharingsAndCredentials;
return execution;
}
}
|