import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; import { IsObject, IsOptional, IsString, IsUUID, IsUrl } from "class-validator"; export class ExecDto { @ApiPropertyOptional({ description: "Optional named browser session. If it does not exist yet, it is created automatically.", example: "test-session-1", }) @IsOptional() @IsString() sessionName?: string; @ApiPropertyOptional({ description: "URL to navigate to before executing code. Skipped if omitted.", example: "https://cabinet-liquio-diia-stg.kitsoft.ua/messages", }) @IsOptional() @IsUrl({ require_tld: true, require_protocol: true }) url?: string; @ApiProperty({ description: "Async JavaScript body. Use `context.page` for Playwright, `context.getEnv(key)`, `context.getCredential(alias)`, `context.runSnippet(name, ...args)`.", example: "return await context.page.title();", }) @IsString() code: string; @ApiPropertyOptional({ description: "UUID of an existing environment entity. Its key/value data is available via `context.env` and `context.getEnv()` in the script.", example: "a6a1fca5-0f61-48ed-ae97-011dc7236387", }) @IsOptional() @IsUUID() environmentId?: string; @ApiPropertyOptional({ description: "Map of alias → credential UUID. Each credential is loaded from the DB and available via `context.getCredential(alias)` in the script.", example: { pkcs_key: "e3b0c442-98fc-11d8-9669-0800200c9a66" }, }) @IsOptional() @IsObject() credentials?: Record; }