Files
liqa/server/src/scenario/scenario-version.entity.ts
T
ars9 ff83b6c7da feat(versioning): version scenarios and snippets, bump to 1.16.0
- snapshot scenario and snippet content into version tables on every
  content change; live tables keep holding the latest version
- record the scenario version on each run and copy its steps into the
  run steps, so runs execute and show the version they were created with
- keep run step history when a step is deleted (FK set null)
- pin a snippet version with runSnippet('alias@N')
- add version picker to the run modal and version info across the UI
- add version list/get endpoints and MCP tools
- include version in exports and require it on import, restoring the
  exact version by id + version
2026-09-30 15:24:44 +03:00

60 lines
1.3 KiB
TypeScript

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;
}