()
| 286 | * Invalidates deployment info and versions queries on success. |
| 287 | */ |
| 288 | export function useDeployWorkflow() { |
| 289 | const queryClient = useQueryClient() |
| 290 | |
| 291 | return useMutation({ |
| 292 | mutationFn: async ({ workflowId }: DeployWorkflowVariables): Promise<DeployWorkflowResult> => { |
| 293 | const data = await requestJson(deployWorkflowContract, { |
| 294 | params: { id: workflowId }, |
| 295 | }) |
| 296 | return { |
| 297 | isDeployed: data.isDeployed ?? false, |
| 298 | deployedAt: data.deployedAt ?? undefined, |
| 299 | apiKey: data.apiKey ?? undefined, |
| 300 | warnings: data.warnings, |
| 301 | } |
| 302 | }, |
| 303 | onSettled: (_data, error, variables) => { |
| 304 | if (error) { |
| 305 | logger.error('Failed to deploy workflow', { error }) |
| 306 | return invalidateDeploymentQueries(queryClient, variables.workflowId) |
| 307 | } |
| 308 | logger.info('Workflow deployed successfully', { workflowId: variables.workflowId }) |
| 309 | return refetchDeploymentBoundary(queryClient, variables.workflowId) |
| 310 | }, |
| 311 | }) |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Variables for undeploy workflow mutation |
no test coverage detected