feat(scenario): run logs, lint/format tooling, CONTRIBUTING
- add ScenarioRunLogEntity to persist step script output to DB - stepLogger dual-writes to NestJS logger and DB (fire-and-forget) - add GET /scenarios/:id/run/:runId returning run, stepRuns and logs - add POST /scenarios/:id/run/:runId/wait (polls until terminal state) - 9 new integration tests for the two endpoints (136 total) - add eslint with typescript-eslint and eslint-config-prettier - add npm scripts: format, lint, lint:fix - resolve all lint errors across src and test (no any types) - add CONTRIBUTING.md covering dev workflow
This commit is contained in:
1 parent
b0c02a1cdc
commit
9a9ccbfe37
67 files changed
+3809
-1412
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { BrowserService, ExecResult, OpenResult } from './browser.service';
|
||||
import { CodeExecutorService } from '../code-executor/code-executor.service';
|
||||
import { OpenDto } from './dto/open.dto';
|
||||
import { ExecDto } from './dto/exec.dto';
|
||||
import { Body, Controller, Post } from "@nestjs/common";
|
||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { BrowserService, ExecResult, OpenResult } from "./browser.service";
|
||||
import { CodeExecutorService } from "../code-executor/code-executor.service";
|
||||
import { OpenDto } from "./dto/open.dto";
|
||||
import { ExecDto } from "./dto/exec.dto";
|
||||
|
||||
@ApiTags('browser')
|
||||
@ApiTags("browser")
|
||||
@Controller()
|
||||
export class BrowserController {
|
||||
constructor(
|
||||
@@ -13,39 +13,47 @@ export class BrowserController {
|
||||
private readonly codeExecutor: CodeExecutorService,
|
||||
) {}
|
||||
|
||||
@Post('open')
|
||||
@ApiOperation({ summary: 'Open a URL with a stored session (cookies + localStorage)' })
|
||||
@Post("open")
|
||||
@ApiOperation({
|
||||
summary: "Open a URL with a stored session (cookies + localStorage)",
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'Page loaded successfully',
|
||||
description: "Page loaded successfully",
|
||||
schema: {
|
||||
properties: {
|
||||
url: { type: 'string' },
|
||||
title: { type: 'string' },
|
||||
content: { type: 'string' },
|
||||
url: { type: "string" },
|
||||
title: { type: "string" },
|
||||
content: { type: "string" },
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiResponse({ status: 400, description: 'Invalid input' })
|
||||
@ApiResponse({ status: 404, description: 'Session not found' })
|
||||
@ApiResponse({ status: 500, description: 'Browser automation failed' })
|
||||
@ApiResponse({ status: 400, description: "Invalid input" })
|
||||
@ApiResponse({ status: 404, description: "Session not found" })
|
||||
@ApiResponse({ status: 500, description: "Browser automation failed" })
|
||||
open(@Body() dto: OpenDto): Promise<OpenResult> {
|
||||
return this.browserService.open(dto.sessionName, dto.url, dto.readerMode ?? false, dto.selector);
|
||||
return this.browserService.open(
|
||||
dto.sessionName,
|
||||
dto.url,
|
||||
dto.readerMode ?? false,
|
||||
dto.selector,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('exec')
|
||||
@Post("exec")
|
||||
@ApiOperation({
|
||||
summary: 'Execute custom Playwright JavaScript within a stored session',
|
||||
description: 'The `code` string is executed as an async function body with `page` (Playwright Page) and `context` (BrowserContext) in scope. The return value is serialised and returned as `result`.',
|
||||
summary: "Execute custom Playwright JavaScript within a stored session",
|
||||
description:
|
||||
"The `code` string is executed as an async function body with `page` (Playwright Page) and `context` (BrowserContext) in scope. The return value is serialised and returned as `result`.",
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'Code executed successfully',
|
||||
description: "Code executed successfully",
|
||||
schema: { properties: { result: {} } },
|
||||
})
|
||||
@ApiResponse({ status: 400, description: 'Invalid input' })
|
||||
@ApiResponse({ status: 404, description: 'Session not found' })
|
||||
@ApiResponse({ status: 500, description: 'Execution failed' })
|
||||
@ApiResponse({ status: 400, description: "Invalid input" })
|
||||
@ApiResponse({ status: 404, description: "Session not found" })
|
||||
@ApiResponse({ status: 500, description: "Execution failed" })
|
||||
exec(@Body() dto: ExecDto): Promise<ExecResult> {
|
||||
this.codeExecutor.validate(dto.code);
|
||||
return this.browserService.exec(dto.sessionName, dto.code, dto.url);
|
||||
|
||||
Reference in new issue
Block a user