- 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)
83 lines
2.8 KiB
TypeScript
83 lines
2.8 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 { CredentialOrderBy, CredentialService } from "./credential.service";
|
|
import { CreateCredentialDto } from "./dto/create-credential.dto";
|
|
import { CredentialExportDto } from "./dto/credential-export.dto";
|
|
import { UpdateCredentialDto } from "./dto/update-credential.dto";
|
|
|
|
@ApiTags("credentials")
|
|
@Controller("credentials")
|
|
export class CredentialController {
|
|
constructor(private readonly credentialService: CredentialService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: "Create a new credential" })
|
|
@ApiResponse({ status: 201, description: "Credential created" })
|
|
create(@Body() dto: CreateCredentialDto) {
|
|
return this.credentialService.create(dto);
|
|
}
|
|
|
|
@Post("import")
|
|
@ApiOperation({ summary: "Import a credential (upsert by id)" })
|
|
@ApiResponse({ status: 201, description: "Credential imported" })
|
|
async importCredential(@Body() dto: CredentialExportDto) {
|
|
return this.credentialService.importCredential(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: "List all credentials (paginated)" })
|
|
@ApiResponse({ status: 200, description: "Paginated credentials" })
|
|
findAll(@Query() query: PaginationQueryDto<CredentialOrderBy>) {
|
|
return this.credentialService.findAll(query);
|
|
}
|
|
|
|
@Get(":id/export")
|
|
@ApiOperation({ summary: "Export a credential as a plain object" })
|
|
@ApiResponse({ status: 200, description: "Credential export payload" })
|
|
@ApiResponse({ status: 404, description: "Credential not found" })
|
|
async exportCredential(@Param("id", ParseUUIDPipe) id: string) {
|
|
const credential = await this.credentialService.findOne(id);
|
|
return this.credentialService.exportCredential(credential);
|
|
}
|
|
|
|
@Get(":id")
|
|
@ApiOperation({ summary: "Get credential by ID" })
|
|
@ApiResponse({ status: 200, description: "Credential record" })
|
|
@ApiResponse({ status: 404, description: "Credential not found" })
|
|
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.credentialService.findOne(id);
|
|
}
|
|
|
|
@Patch(":id")
|
|
@ApiOperation({ summary: "Update a credential" })
|
|
@ApiResponse({ status: 200, description: "Credential updated" })
|
|
@ApiResponse({ status: 404, description: "Credential not found" })
|
|
update(
|
|
@Param("id", ParseUUIDPipe) id: string,
|
|
@Body() dto: UpdateCredentialDto,
|
|
) {
|
|
return this.credentialService.update(id, dto);
|
|
}
|
|
|
|
@Delete(":id")
|
|
@HttpCode(204)
|
|
@ApiOperation({ summary: "Delete a credential" })
|
|
@ApiResponse({ status: 204, description: "Credential deleted" })
|
|
@ApiResponse({ status: 404, description: "Credential not found" })
|
|
remove(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.credentialService.remove(id);
|
|
}
|
|
}
|