(
id: string,
dto: WorkflowGraphDto,
auth?: AuthContext | null,
)
| 310 | } |
| 311 | |
| 312 | async update( |
| 313 | id: string, |
| 314 | dto: WorkflowGraphDto, |
| 315 | auth?: AuthContext | null, |
| 316 | ): Promise<ServiceWorkflowResponse> { |
| 317 | const input = this.parse(dto); |
| 318 | |
| 319 | // Validate workflow graph before saving (including port connections) |
| 320 | try { |
| 321 | compileWorkflowGraph(input); |
| 322 | } catch (error) { |
| 323 | if (error instanceof Error) { |
| 324 | throw new BadRequestException(`Workflow validation failed: ${error.message}`); |
| 325 | } |
| 326 | throw error; |
| 327 | } |
| 328 | |
| 329 | const organizationId = await this.requireWorkflowAdmin(id, auth); |
| 330 | const record = await this.repository.update(id, input, { organizationId }); |
| 331 | const version = await this.versionRepository.create({ |
| 332 | workflowId: record.id, |
| 333 | graph: input, |
| 334 | organizationId, |
| 335 | }); |
| 336 | const response = this.buildWorkflowResponse(record, version); |
| 337 | this.logger.log( |
| 338 | `Updated workflow ${response.id} to version ${version.version} (nodes=${input.nodes.length}, edges=${input.edges.length})`, |
| 339 | ); |
| 340 | return response; |
| 341 | } |
| 342 | |
| 343 | async updateMetadata( |
| 344 | id: string, |
no test coverage detected