- POST /exec now accepts environmentId (UUID) and credentials (alias → UUID) instead of raw payloads; resolves entities via EnvironmentService and CredentialService before passing data to browserService.exec - exec_code MCP tool updated with same schema: environmentId + credentials map - CredentialModule imported into BrowserModule and McpModule - docs(scenario): rewrite script runtime section for single context argument - docs(mcp): update exec_code description to reflect new parameter shapes - style: reorder imports across server source (formatter)
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from "@nestjs/common";
|
|
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
|
import { PaginationQueryDto } from "../common/dto/pagination.dto";
|
|
import { CreateEnvironmentDto } from "./dto/create-environment.dto";
|
|
import { EnvironmentExportDto } from "./dto/environment-export.dto";
|
|
import { UpdateEnvironmentDto } from "./dto/update-environment.dto";
|
|
import { EnvironmentOrderBy, EnvironmentService } from "./environment.service";
|
|
|
|
@ApiTags("environments")
|
|
@Controller("environments")
|
|
export class EnvironmentController {
|
|
constructor(private readonly environmentService: EnvironmentService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: "Create a new environment" })
|
|
@ApiResponse({ status: 201, description: "Environment created" })
|
|
@ApiResponse({ status: 409, description: "Environment name already exists" })
|
|
create(@Body() dto: CreateEnvironmentDto) {
|
|
return this.environmentService.create(dto);
|
|
}
|
|
|
|
@Post("import")
|
|
@ApiOperation({ summary: "Import an environment (upsert by id or name)" })
|
|
@ApiResponse({ status: 201, description: "Environment imported" })
|
|
async importEnvironment(@Body() dto: EnvironmentExportDto) {
|
|
return this.environmentService.importEnvironment(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: "List all environments (paginated)" })
|
|
@ApiResponse({ status: 200, description: "Paginated environments" })
|
|
findAll(@Query() query: PaginationQueryDto<EnvironmentOrderBy>) {
|
|
return this.environmentService.findAll(query);
|
|
}
|
|
|
|
@Get(":id/export")
|
|
@ApiOperation({ summary: "Export an environment as a plain object" })
|
|
@ApiResponse({ status: 200, description: "Environment export payload" })
|
|
@ApiResponse({ status: 404, description: "Environment not found" })
|
|
async exportEnvironment(@Param("id", ParseUUIDPipe) id: string) {
|
|
const env = await this.environmentService.findOne(id);
|
|
return this.environmentService.exportEnvironment(env);
|
|
}
|
|
|
|
@Get(":id")
|
|
@ApiOperation({ summary: "Get environment by ID" })
|
|
@ApiResponse({ status: 200, description: "Environment record" })
|
|
@ApiResponse({ status: 404, description: "Environment not found" })
|
|
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.environmentService.findOne(id);
|
|
}
|
|
|
|
@Patch(":id")
|
|
@ApiOperation({ summary: "Update an environment" })
|
|
@ApiResponse({ status: 200, description: "Environment updated" })
|
|
@ApiResponse({ status: 404, description: "Environment not found" })
|
|
update(
|
|
@Param("id", ParseUUIDPipe) id: string,
|
|
@Body() dto: UpdateEnvironmentDto,
|
|
) {
|
|
return this.environmentService.update(id, dto);
|
|
}
|
|
|
|
@Delete(":id")
|
|
@HttpCode(204)
|
|
@ApiOperation({ summary: "Delete an environment" })
|
|
@ApiResponse({ status: 204, description: "Environment deleted" })
|
|
@ApiResponse({ status: 404, description: "Environment not found" })
|
|
remove(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.environmentService.remove(id);
|
|
}
|
|
}
|