Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 6e67be8

Browse files
authored
Merge pull request #160 from DataFlowAnalysis/json-version
add version to json
2 parents 7904f15 + 8b1ca0d commit 6e67be8

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/features/serialize/analyze.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
66
import { EditorModeController } from "../editorMode/editorModeController";
77
import { sendMessage } from "./webSocketHandler";
88
import { ConstraintRegistry } from "../constraintMenu/constraintRegistry";
9-
import { SavedDiagram } from "./save";
9+
import { CURRENT_VERSION, SavedDiagram } from "./save";
1010
import { LoadingIndicator } from "../../common/loadingIndicator";
1111

1212
export interface AnalyzeDiagramAction extends Action {
@@ -62,6 +62,7 @@ export class AnalyzeDiagramCommand extends Command {
6262
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
6363
constraints: this.constraintRegistry?.getConstraints(),
6464
mode: this.editorModeController?.getCurrentMode(),
65+
version: CURRENT_VERSION,
6566
};
6667
const diagramJson = JSON.stringify(diagram, undefined, 4);
6768
sendMessage("Json:" + diagramJson);

src/features/serialize/defaultDiagram.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,5 +619,6 @@
619619
"constraint": "data Sensitivity.Personal neverFlows vertex Location.nonEU"
620620
}
621621
],
622-
"mode": "edit"
622+
"mode": "edit",
623+
"version": 1
623624
}

src/features/serialize/save.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export interface SavedDiagram {
1515
labelTypes?: LabelType[];
1616
constraints?: Constraint[];
1717
mode?: EditorMode;
18+
version: number;
1819
}
20+
export const CURRENT_VERSION = 1;
1921

2022
export interface SaveDiagramAction extends Action {
2123
kind: typeof SaveDiagramAction.KIND;
@@ -66,6 +68,7 @@ export class SaveDiagramCommand extends Command {
6668
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
6769
constraints: this.constraintRegistry?.getConstraints(),
6870
mode: this.editorModeController?.getCurrentMode(),
71+
version: CURRENT_VERSION,
6972
};
7073
const diagramJson = JSON.stringify(diagram, undefined, 4);
7174
const jsonBlob = new Blob([diagramJson], { type: "application/json" });

src/features/serialize/saveDFDandDD.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LabelTypeRegistry } from "../labels/labelTypeRegistry";
55
import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
66
import { EditorModeController } from "../editorMode/editorModeController";
77
import { sendMessage } from "./webSocketHandler";
8-
import { SavedDiagram } from "./save";
8+
import { CURRENT_VERSION, SavedDiagram } from "./save";
99
import { ConstraintRegistry } from "../constraintMenu/constraintRegistry";
1010
import { getModelFileName } from "../../index";
1111

@@ -58,6 +58,7 @@ export class SaveDFDandDDCommand extends Command {
5858
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
5959
constraints: this.constraintRegistry?.getConstraints(),
6060
mode: this.editorModeController?.getCurrentMode(),
61+
version: CURRENT_VERSION,
6162
};
6263
const diagramJson = JSON.stringify(diagram, undefined, 4);
6364
sendMessage("Json2DFD:" + getModelFileName() + ":" + diagramJson);

0 commit comments

Comments
 (0)