n8n/packages/cli/src/evaluation/tests.service.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
999 B
TypeScript
Raw Normal View History

2024-11-01 08:13:31 -07:00
import { Service } from 'typedi';
import type { TestEntity } from '@/databases/entities/test-entity';
// import type { User } from '@/databases/entities/user';
import { TestRepository } from '@/databases/repositories/test.repository';
import { validateEntity } from '@/generic-helpers';
// import type { ListQuery } from '@/requests';
@Service()
export class TestsService {
constructor(private testRepository: TestRepository) {}
// toEntity(attrs: { name: string; id?: string }) {
// attrs.name = attrs.name.trim();
//
// return this.testRepository.create(attrs);
// }
async save(test: TestEntity) {
await validateEntity(test);
return await this.testRepository.save(test);
}
async delete(id: string) {
return await this.testRepository.delete(id);
}
async getMany(/*user: User, options: ListQuery.Options*/) {
const allTests = await this.testRepository.find({
select: ['id', 'name', 'createdAt', 'updatedAt'],
});
return { allTests, count: allTests.length };
}
}