import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, } from "typeorm"; import { ScenarioRunStepEntity } from "./scenario-run-step.entity"; import { ScenarioRunEntity } from "./scenario-run.entity"; export type LogLevel = "log" | "warn" | "error"; @Entity("scenario_run_logs") export class ScenarioRunLogEntity { @PrimaryGeneratedColumn("uuid") id: string; @Column("text") runId: string; @ManyToOne(() => ScenarioRunEntity, { onDelete: "CASCADE" }) @JoinColumn({ name: "runId" }) run: ScenarioRunEntity; @Column({ type: "text", nullable: true }) stepRunId: string | null; @ManyToOne(() => ScenarioRunStepEntity, { onDelete: "SET NULL", nullable: true, }) @JoinColumn({ name: "stepRunId" }) stepRun: ScenarioRunStepEntity | null; @Column({ type: "text", default: "log" }) level: LogLevel; @Column({ type: "text" }) message: string; // Assigned in call order per run, since concurrent unawaited writes can // otherwise persist out of order (createdAt alone isn't a reliable tiebreaker). @Column({ type: "int", default: 0 }) seq: number; @CreateDateColumn() createdAt: Date; }