(id: string, auth?: AuthContext | null)
| 705 | } |
| 706 | |
| 707 | async commit(id: string, auth?: AuthContext | null): Promise<WorkflowDefinition> { |
| 708 | const organizationId = await this.requireWorkflowAdmin(id, auth); |
| 709 | const workflow = await this.repository.findById(id, { organizationId }); |
| 710 | if (!workflow) { |
| 711 | throw new NotFoundException(`Workflow ${id} not found`); |
| 712 | } |
| 713 | |
| 714 | const version = await this.versionRepository.findLatestByWorkflowId(id, { |
| 715 | organizationId, |
| 716 | }); |
| 717 | if (!version) { |
| 718 | throw new NotFoundException(`No versions recorded for workflow ${id}`); |
| 719 | } |
| 720 | |
| 721 | this.logger.log(`Compiling workflow ${workflow.id} version ${version.version}`); |
| 722 | const graph = WorkflowGraphSchema.parse(version.graph); |
| 723 | const definition = compileWorkflowGraph(graph); |
| 724 | await this.repository.saveCompiledDefinition(id, definition, { organizationId }); |
| 725 | await this.versionRepository.setCompiledDefinition(version.id, definition, { |
| 726 | organizationId, |
| 727 | }); |
| 728 | this.logger.log( |
| 729 | `Compiled workflow ${workflow.id} version ${version.version} with ${definition.actions.length} action(s); entrypoint=${definition.entrypoint.ref}`, |
| 730 | ); |
| 731 | return definition; |
| 732 | } |
| 733 | |
| 734 | async run( |
| 735 | id: string, |
no test coverage detected