62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from "typeorm";
|
|
import { EnvironmentEntity } from "../environment/environment.entity";
|
|
import { SessionEntity } from "../session/session.entity";
|
|
import { ScenarioRunStepEntity } from "./scenario-run-step.entity";
|
|
import { ScenarioEntity } from "./scenario.entity";
|
|
|
|
export type RunStatus = "pending" | "in_progress" | "pass" | "fail";
|
|
|
|
@Entity("scenario_runs")
|
|
export class ScenarioRunEntity {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id: string;
|
|
|
|
@Column("text")
|
|
scenarioId: string;
|
|
|
|
@Column("text", { nullable: true, default: null })
|
|
environmentId: string | null;
|
|
|
|
@ManyToOne(() => ScenarioEntity, { onDelete: "CASCADE" })
|
|
@JoinColumn({ name: "scenarioId" })
|
|
scenario: ScenarioEntity;
|
|
|
|
@ManyToOne(() => EnvironmentEntity, { onDelete: "SET NULL", nullable: true })
|
|
@JoinColumn({ name: "environmentId" })
|
|
environment: EnvironmentEntity;
|
|
|
|
@Column("text", { nullable: true, default: null })
|
|
sessionId: string | null;
|
|
|
|
@ManyToOne(() => SessionEntity, { onDelete: "SET NULL", nullable: true })
|
|
@JoinColumn({ name: "sessionId" })
|
|
session: SessionEntity | null;
|
|
|
|
@Column({ type: "text", default: "pending" })
|
|
status: RunStatus;
|
|
|
|
@Column({ type: "boolean", default: false })
|
|
saveSession: boolean;
|
|
|
|
@OneToMany(() => ScenarioRunStepEntity, (rs) => rs.run, {
|
|
cascade: true,
|
|
eager: false,
|
|
})
|
|
stepRuns: ScenarioRunStepEntity[];
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|