feat(core): Execution curation (#10342)

Co-authored-by: oleg <me@olegivaniv.com>
This commit is contained in:
Eugene
2024-09-02 15:20:08 +02:00
committed by GitHub
parent 8603946e23
commit 022ddcbef9
75 changed files with 2733 additions and 713 deletions

View File

@@ -1,6 +1,7 @@
import { ExecutionRequest, type ExecutionSummaries } from './execution.types';
import { ExecutionService } from './execution.service';
import { Get, Post, RestController } from '@/decorators';
import { validateExecutionUpdatePayload } from './validation';
import { Get, Patch, Post, RestController } from '@/decorators';
import { EnterpriseExecutionsService } from './execution.service.ee';
import { License } from '@/license';
import { WorkflowSharingService } from '@/workflows/workflow-sharing.service';
@@ -47,7 +48,10 @@ export class ExecutionsController {
query.accessibleWorkflowIds = accessibleWorkflowIds;
if (!this.license.isAdvancedExecutionFiltersEnabled()) delete query.metadata;
if (!this.license.isAdvancedExecutionFiltersEnabled()) {
delete query.metadata;
delete query.annotationTags;
}
const noStatus = !query.status || query.status.length === 0;
const noRange = !query.range.lastId || !query.range.firstId;
@@ -110,4 +114,23 @@ export class ExecutionsController {
return await this.executionService.delete(req, workflowIds);
}
@Patch('/:id')
async update(req: ExecutionRequest.Update) {
if (!isPositiveInteger(req.params.id)) {
throw new BadRequestError('Execution ID is not a number');
}
const workflowIds = await this.getAccessibleWorkflowIds(req.user, 'workflow:read');
// Fail fast if no workflows are accessible
if (workflowIds.length === 0) throw new NotFoundError('Execution not found');
const { body: payload } = req;
const validatedPayload = validateExecutionUpdatePayload(payload);
await this.executionService.annotate(req.params.id, validatedPayload, workflowIds);
return await this.executionService.findOne(req, workflowIds);
}
}