import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Unique, } from "typeorm"; import { ScenarioEntity } from "./scenario.entity"; /** A step as it was at a given scenario version. */ export interface ScenarioStepSnapshot { /** Id of the live step this snapshot was taken from (may no longer exist). */ id: string | null; order: number; title: string | null; execCode: string | null; timeoutSeconds: number | null; } /** * Immutable snapshot of a scenario's content at one version. The `scenarios` * and `scenario_steps` tables always hold the latest version. */ @Entity("scenario_versions") @Unique(["scenarioId", "version"]) export class ScenarioVersionEntity { @PrimaryGeneratedColumn("uuid") id: string; @Column("text") scenarioId: string; @ManyToOne(() => ScenarioEntity, { onDelete: "CASCADE" }) @JoinColumn({ name: "scenarioId" }) scenario: ScenarioEntity; @Column({ type: "int" }) version: number; @Column() name: string; @Column("text", { nullable: true }) description: string | null; @Column({ type: "text", nullable: true }) environmentId: string | null; @Column({ type: "int", nullable: true }) timeoutSeconds: number | null; @Column("simple-json") steps: ScenarioStepSnapshot[]; @CreateDateColumn() createdAt: Date; }