- list the snippets a scenario uses in the export dialog, checked by default, with the versions the scenario uses - export each selected snippet once per used version (latest and pinned) via the new snippetIds query parameter - resolve used snippets from the exported version's steps - show the scenario version in the export dialog - document the export query parameters - bump version to 1.22.0
160 lines
2.9 KiB
TypeScript
160 lines
2.9 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";
|
|
import { SnippetExportDto } from "../../snippet/dto/snippet-export.dto";
|
|
|
|
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
|
|
| SnippetExportDto
|
|
| ScenarioExportDto;
|