diff --git a/packages/cli/src/evaluation/tests.controller.ts b/packages/cli/src/evaluation/tests.controller.ts index da7249e8dc..9f0ac0b4a0 100644 --- a/packages/cli/src/evaluation/tests.controller.ts +++ b/packages/cli/src/evaluation/tests.controller.ts @@ -16,7 +16,7 @@ export class TestsController { async getMany(req: TestsRequest.GetMany) { const workflowIds = await getSharedWorkflowIds(req.user, ['workflow:read']); - return await this.testsService.getMany(req.user, req.listQueryOptions, workflowIds); + return await this.testsService.getMany(req.listQueryOptions, workflowIds); } @Get('/:id') diff --git a/packages/cli/src/evaluation/tests.service.ts b/packages/cli/src/evaluation/tests.service.ts index 9efa18bfa1..0463e57be6 100644 --- a/packages/cli/src/evaluation/tests.service.ts +++ b/packages/cli/src/evaluation/tests.service.ts @@ -1,26 +1,32 @@ import { Service } from 'typedi'; -import type { TestEntity } from '@/databases/entities/test-entity'; +import type { TestDefinition } from '@/databases/entities/test-definition'; import type { User } from '@/databases/entities/user'; import { TestRepository } from '@/databases/repositories/test.repository'; import { validateEntity } from '@/generic-helpers'; import type { ListQuery } from '@/requests'; -import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; + +type TestDefinitionLike = Omit< + Partial, + 'workflow' | 'evaluationWorkflow' | 'annotationTag' +> & { + workflow?: { id: string }; + evaluationWorkflow?: { id: string }; + annotationTag?: { id: string }; +}; @Service() export class TestsService { - constructor( - private testRepository: TestRepository, - private readonly workflowSharingService: WorkflowSharingService, - ) {} + constructor(private testRepository: TestRepository) {} toEntity(attrs: { name?: string; workflowId?: string; evaluationWorkflowId?: string; + annotationTagId?: string; id?: number; }) { - const entity = { + const entity: TestDefinitionLike = { name: attrs.name?.trim(), }; @@ -40,6 +46,12 @@ export class TestsService { }; } + if (attrs.annotationTagId) { + entity.annotationTag = { + id: attrs.annotationTagId, + }; + } + return this.testRepository.create(entity); } @@ -57,7 +69,7 @@ export class TestsService { return await this.testRepository.deleteById(id, accessibleWorkflowIds); } - async getMany(user: User, options: ListQuery.Options, accessibleWorkflowIds: string[] = []) { + async getMany(options: ListQuery.Options, accessibleWorkflowIds: string[] = []) { return await this.testRepository.getMany(accessibleWorkflowIds, options); } }