feat(scenarios,environments): add markdown description field

- add optional description to scenario and environment entities
- expose description in create/update DTOs, MCP tools, and export DTOs
- render description as markdown on detail pages
- add description editor (CodeEditor) to create/edit forms for both resources
This commit is contained in:
ars9 committed 2026-04-14 23:53:45 +03:00
1 parent 4dab218b75
commit e6aacc899d
20 files changed
+206 -32

No files matched your search

@@ -1,9 +1,14 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsString } from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString } from "class-validator";
export class CreateScenarioDto {
@ApiProperty({ example: "Login and verify cabinet" })
@IsString()
@IsNotEmpty()
name: string;
@ApiPropertyOptional({ description: "Optional markdown description" })
@IsOptional()
@IsString()
description?: string;
}
@@ -46,6 +46,11 @@ export class ScenarioExportDto {
@IsNotEmpty()
name: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
description?: string;
@ApiProperty({ type: [ScenarioStepExportDto] })
@IsArray()
@ValidateNested({ each: true })
@@ -7,4 +7,9 @@ export class UpdateScenarioDto {
@IsString()
@IsNotEmpty()
name?: string;
@ApiPropertyOptional({ description: "Optional markdown description" })
@IsOptional()
@IsString()
description?: string;
}
+3
View File
@@ -17,6 +17,9 @@ export class ScenarioEntity {
@Column()
name: string;
@Column("text", { nullable: true })
description: string | null;
@OneToMany(() => ScenarioStepEntity, (step) => step.scenario, {
cascade: true,
eager: false,
+11 -2
View File
@@ -410,6 +410,7 @@ export class ScenarioService {
kind: "scenario",
id: scenario.id,
name: scenario.name,
description: scenario.description ?? undefined,
steps: scenario.steps.map((s) => ({
title: s.title,
execCode: s.execCode,
@@ -424,17 +425,25 @@ export class ScenarioService {
const existing = await this.scenarioRepo.findOneBy({ id: dto.id });
if (existing) {
existing.name = dto.name;
existing.description = dto.description ?? null;
scenario = await this.scenarioRepo.save(existing);
// Delete old steps and recreate
await this.stepRepo.delete({ scenarioId: scenario.id });
} else {
scenario = await this.scenarioRepo.save(
this.scenarioRepo.create({ id: dto.id, name: dto.name }),
this.scenarioRepo.create({
id: dto.id,
name: dto.name,
description: dto.description ?? null,
}),
);
}
} else {
scenario = await this.scenarioRepo.save(
this.scenarioRepo.create({ name: dto.name }),
this.scenarioRepo.create({
name: dto.name,
description: dto.description ?? null,
}),
);
}
if (dto.steps.length > 0) {