- snapshot scenario and snippet content into version tables on every
content change; live tables keep holding the latest version
- record the scenario version on each run and copy its steps into the
run steps, so runs execute and show the version they were created with
- keep run step history when a step is deleted (FK set null)
- pin a snippet version with runSnippet('alias@N')
- add version picker to the run modal and version info across the UI
- add version list/get endpoints and MCP tools
- include version in exports and require it on import, restoring the
exact version by id + version
158 lines
2.8 KiB
TypeScript
158 lines
2.8 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { Type } from "class-transformer";
|
|
import {
|
|
IsArray,
|
|
IsIn,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsObject,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
Min,
|
|
ValidateNested,
|
|
} from "class-validator";
|
|
import { EnvironmentData } from "../../environment/environment.entity";
|
|
|
|
export class ScenarioStepExportDto {
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
title: string | null;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
execCode: string | null;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
timeoutSeconds?: number | null;
|
|
}
|
|
|
|
export class CredentialExportDto {
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsIn(["credential"])
|
|
kind?: "credential";
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsUUID()
|
|
id?: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
data?: string | null;
|
|
}
|
|
|
|
export class EnvironmentExportInlineDto {
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsIn(["environment"])
|
|
kind?: "environment";
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsUUID()
|
|
id?: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
description?: string;
|
|
|
|
@ApiProperty()
|
|
@IsObject()
|
|
data: EnvironmentData;
|
|
}
|
|
|
|
export class ScenarioCredentialMappingDto {
|
|
@ApiProperty()
|
|
@IsUUID()
|
|
credentialId: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
alias: string;
|
|
}
|
|
|
|
export class ScenarioExportDto {
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsIn(["scenario"])
|
|
kind?: "scenario";
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsUUID()
|
|
id?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
title?: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
description?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsUUID()
|
|
environmentId?: string;
|
|
|
|
@ApiProperty({ description: "Scenario version this export holds" })
|
|
@IsInt()
|
|
@Min(1)
|
|
version: number;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
timeoutSeconds?: number;
|
|
|
|
@ApiPropertyOptional({ type: [ScenarioCredentialMappingDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => ScenarioCredentialMappingDto)
|
|
credentials?: ScenarioCredentialMappingDto[];
|
|
|
|
@ApiProperty({ type: [ScenarioStepExportDto] })
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => ScenarioStepExportDto)
|
|
steps: ScenarioStepExportDto[];
|
|
}
|
|
|
|
/** Union type for multi-entity export array items */
|
|
export type ExportEntity =
|
|
| EnvironmentExportInlineDto
|
|
| CredentialExportDto
|
|
| ScenarioExportDto;
|