feat(#168): Implement job steps tracking
Implement JobStepsModule for granular step tracking within runner jobs. Features: - Create and track job steps (SETUP, EXECUTION, VALIDATION, CLEANUP) - Track step status transitions (PENDING → RUNNING → COMPLETED/FAILED) - Record token usage for AI_ACTION steps - Calculate step duration automatically - GET endpoints for listing and retrieving steps Implementation: - JobStepsService: CRUD operations, status tracking, duration calculation - JobStepsController: GET /runner-jobs/:jobId/steps endpoints - DTOs: CreateStepDto, UpdateStepDto with validation - Full unit test coverage (16 tests) Quality gates: - Build: ✅ Passed - Lint: ✅ Passed - Tests: ✅ 16/16 passed - Coverage: ✅ 100% statements, 100% functions, 100% lines, 83.33% branches Also fixed pre-existing TypeScript strict mode issue in job-events DTO. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
26
apps/api/src/job-steps/dto/create-step.dto.ts
Normal file
26
apps/api/src/job-steps/dto/create-step.dto.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { JobStepPhase, JobStepType, JobStepStatus } from "@prisma/client";
|
||||
import { IsString, IsEnum, IsInt, IsOptional, MinLength, MaxLength, Min } from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for creating a new job step
|
||||
*/
|
||||
export class CreateStepDto {
|
||||
@IsInt({ message: "ordinal must be an integer" })
|
||||
@Min(0, { message: "ordinal must be at least 0" })
|
||||
ordinal!: number;
|
||||
|
||||
@IsEnum(JobStepPhase, { message: "phase must be a valid JobStepPhase" })
|
||||
phase!: JobStepPhase;
|
||||
|
||||
@IsString({ message: "name must be a string" })
|
||||
@MinLength(1, { message: "name must not be empty" })
|
||||
@MaxLength(200, { message: "name must not exceed 200 characters" })
|
||||
name!: string;
|
||||
|
||||
@IsEnum(JobStepType, { message: "type must be a valid JobStepType" })
|
||||
type!: JobStepType;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(JobStepStatus, { message: "status must be a valid JobStepStatus" })
|
||||
status?: JobStepStatus;
|
||||
}
|
||||
2
apps/api/src/job-steps/dto/index.ts
Normal file
2
apps/api/src/job-steps/dto/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./create-step.dto";
|
||||
export * from "./update-step.dto";
|
||||
25
apps/api/src/job-steps/dto/update-step.dto.ts
Normal file
25
apps/api/src/job-steps/dto/update-step.dto.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { JobStepStatus } from "@prisma/client";
|
||||
import { IsEnum, IsString, IsOptional, IsInt, Min } from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for updating a job step
|
||||
*/
|
||||
export class UpdateStepDto {
|
||||
@IsOptional()
|
||||
@IsEnum(JobStepStatus, { message: "status must be a valid JobStepStatus" })
|
||||
status?: JobStepStatus;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "output must be a string" })
|
||||
output?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt({ message: "tokensInput must be an integer" })
|
||||
@Min(0, { message: "tokensInput must be at least 0" })
|
||||
tokensInput?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt({ message: "tokensOutput must be an integer" })
|
||||
@Min(0, { message: "tokensOutput must be at least 0" })
|
||||
tokensOutput?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user