mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-07-31 17:17:23 +02:00
19 lines
579 B
TypeScript
19 lines
579 B
TypeScript
import { WorkflowRepository } from '@n8n/db';
|
|
import { Service } from '@n8n/di';
|
|
import { UnexpectedError, type IWorkflowBase, type IWorkflowLoader } from 'n8n-workflow';
|
|
|
|
@Service()
|
|
export class WorkflowLoaderService implements IWorkflowLoader {
|
|
constructor(private readonly workflowRepository: WorkflowRepository) {}
|
|
|
|
async get(workflowId: string): Promise<IWorkflowBase> {
|
|
const workflow = await this.workflowRepository.findById(workflowId);
|
|
|
|
if (!workflow) {
|
|
throw new UnexpectedError(`Failed to find workflow with ID "${workflowId}"`);
|
|
}
|
|
|
|
return workflow;
|
|
}
|
|
}
|