callman-core 1.26.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-packs/db-queries.md +10 -1
- package/ai-packs/diagram-components.md +373 -0
- package/dist/curl/bodyFormat.d.ts +4 -0
- package/dist/curl/bodyFormat.d.ts.map +1 -0
- package/dist/curl/bodyFormat.js +80 -0
- package/dist/curl/bodyFormat.js.map +1 -0
- package/dist/curl/index.d.ts +5 -0
- package/dist/curl/index.d.ts.map +1 -0
- package/dist/curl/index.js +4 -0
- package/dist/curl/index.js.map +1 -0
- package/dist/curl/parseCurl.d.ts +4 -0
- package/dist/curl/parseCurl.d.ts.map +1 -0
- package/dist/curl/parseCurl.js +288 -0
- package/dist/curl/parseCurl.js.map +1 -0
- package/dist/curl/rows.d.ts +6 -0
- package/dist/curl/rows.d.ts.map +1 -0
- package/dist/curl/rows.js +23 -0
- package/dist/curl/rows.js.map +1 -0
- package/dist/curl/types.d.ts +21 -0
- package/dist/curl/types.d.ts.map +1 -0
- package/dist/curl/types.js +6 -0
- package/dist/curl/types.js.map +1 -0
- package/dist/diagram/componentCatalog.d.ts +31 -0
- package/dist/diagram/componentCatalog.d.ts.map +1 -0
- package/dist/diagram/componentCatalog.data.d.ts +3 -0
- package/dist/diagram/componentCatalog.data.d.ts.map +1 -0
- package/dist/diagram/componentCatalog.data.js +287 -0
- package/dist/diagram/componentCatalog.data.js.map +1 -0
- package/dist/diagram/componentCatalog.js +71 -0
- package/dist/diagram/componentCatalog.js.map +1 -0
- package/dist/diagram/edgeSemantics.d.ts +28 -0
- package/dist/diagram/edgeSemantics.d.ts.map +1 -0
- package/dist/diagram/edgeSemantics.js +78 -0
- package/dist/diagram/edgeSemantics.js.map +1 -0
- package/dist/diagram/elkGraph.d.ts +80 -0
- package/dist/diagram/elkGraph.d.ts.map +1 -0
- package/dist/diagram/elkGraph.js +283 -0
- package/dist/diagram/elkGraph.js.map +1 -0
- package/dist/diagram/index.d.ts +7 -0
- package/dist/diagram/index.d.ts.map +1 -0
- package/dist/diagram/index.js +13 -0
- package/dist/diagram/index.js.map +1 -0
- package/dist/diagram/migrations.d.ts +3 -0
- package/dist/diagram/migrations.d.ts.map +1 -0
- package/dist/diagram/migrations.js +33 -0
- package/dist/diagram/migrations.js.map +1 -0
- package/dist/diagram/normalize.d.ts +4 -0
- package/dist/diagram/normalize.d.ts.map +1 -0
- package/dist/diagram/normalize.js +68 -0
- package/dist/diagram/normalize.js.map +1 -0
- package/dist/diagram/schema.d.ts +116 -0
- package/dist/diagram/schema.d.ts.map +1 -0
- package/dist/diagram/schema.js +135 -0
- package/dist/diagram/schema.js.map +1 -0
- package/dist/http-file/detect.d.ts +12 -0
- package/dist/http-file/detect.d.ts.map +1 -0
- package/dist/http-file/detect.js +108 -0
- package/dist/http-file/detect.js.map +1 -0
- package/dist/http-file/flatImport.d.ts +32 -0
- package/dist/http-file/flatImport.d.ts.map +1 -0
- package/dist/http-file/flatImport.js +102 -0
- package/dist/http-file/flatImport.js.map +1 -0
- package/dist/http-file/index.d.ts +4 -0
- package/dist/http-file/index.d.ts.map +1 -0
- package/dist/http-file/index.js +7 -0
- package/dist/http-file/index.js.map +1 -0
- package/dist/http-file/parseHttpFile.d.ts +12 -0
- package/dist/http-file/parseHttpFile.d.ts.map +1 -0
- package/dist/http-file/parseHttpFile.js +122 -0
- package/dist/http-file/parseHttpFile.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.js +41 -0
- package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist/scenario-runner/runScenario.d.ts.map +1 -1
- package/dist/scenario-runner/runScenario.js +112 -0
- package/dist/scenario-runner/runScenario.js.map +1 -1
- package/dist/scenario-runner/types.d.ts +17 -0
- package/dist/scenario-runner/types.d.ts.map +1 -1
- package/dist-cjs/curl/bodyFormat.js +85 -0
- package/dist-cjs/curl/bodyFormat.js.map +1 -0
- package/dist-cjs/curl/index.js +15 -0
- package/dist-cjs/curl/index.js.map +1 -0
- package/dist-cjs/curl/parseCurl.js +293 -0
- package/dist-cjs/curl/parseCurl.js.map +1 -0
- package/dist-cjs/curl/rows.js +30 -0
- package/dist-cjs/curl/rows.js.map +1 -0
- package/dist-cjs/curl/types.js +7 -0
- package/dist-cjs/curl/types.js.map +1 -0
- package/dist-cjs/diagram/componentCatalog.data.js +290 -0
- package/dist-cjs/diagram/componentCatalog.data.js.map +1 -0
- package/dist-cjs/diagram/componentCatalog.js +79 -0
- package/dist-cjs/diagram/componentCatalog.js.map +1 -0
- package/dist-cjs/diagram/edgeSemantics.js +86 -0
- package/dist-cjs/diagram/edgeSemantics.js.map +1 -0
- package/dist-cjs/diagram/elkGraph.js +293 -0
- package/dist-cjs/diagram/elkGraph.js.map +1 -0
- package/dist-cjs/diagram/index.js +33 -0
- package/dist-cjs/diagram/index.js.map +1 -0
- package/dist-cjs/diagram/migrations.js +37 -0
- package/dist-cjs/diagram/migrations.js.map +1 -0
- package/dist-cjs/diagram/normalize.js +73 -0
- package/dist-cjs/diagram/normalize.js.map +1 -0
- package/dist-cjs/diagram/schema.js +144 -0
- package/dist-cjs/diagram/schema.js.map +1 -0
- package/dist-cjs/http-file/detect.js +113 -0
- package/dist-cjs/http-file/detect.js.map +1 -0
- package/dist-cjs/http-file/flatImport.js +109 -0
- package/dist-cjs/http-file/flatImport.js.map +1 -0
- package/dist-cjs/http-file/index.js +20 -0
- package/dist-cjs/http-file/index.js.map +1 -0
- package/dist-cjs/http-file/parseHttpFile.js +127 -0
- package/dist-cjs/http-file/parseHttpFile.js.map +1 -0
- package/dist-cjs/index.js +5 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/request-executor.js +41 -0
- package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist-cjs/scenario-runner/runScenario.js +112 -0
- package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edgeSemantics.d.ts","sourceRoot":"","sources":["../../src/diagram/edgeSemantics.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;AAGjE,eAAO,MAAM,aAAa;;;CAA4C,CAAC;AAEvE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,YAAY,EAAE,gBAAgB,CA6BjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAAY,EAAyC,CAAC;AAExF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,GAAI,QAAQ,cAAc,KAAG,YAK1D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,YAAY,KAAG,YAOtD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YACuB,CAAC;AAIjF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OAK7D,CAAC;AAIF,eAAO,MAAM,kBAAkB,GAAI,OAAO,cAAc,GAAG,SAAS,KAAG,OAC0B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// The edge NOTATION: a diagram's edges carry ~60% of its meaning, so the four
|
|
2
|
+
// connection kinds get a fixed visual language instead of ad-hoc dashes.
|
|
3
|
+
//
|
|
4
|
+
// sync solid, normal weight — request/response call
|
|
5
|
+
// async long dash — fire-and-forget / event
|
|
6
|
+
// fallback dotted, thinner — retry, fallback or optional path
|
|
7
|
+
// bus solid, heavy — message bus / stream (Kafka, queues)
|
|
8
|
+
//
|
|
9
|
+
// The semantic is DERIVED from the style tuple (dashed + dashPattern +
|
|
10
|
+
// strokeWidth) rather than stored as a field: every existing diagram gains the
|
|
11
|
+
// notation for free and the document schema does not move.
|
|
12
|
+
import { getDiagramComponent } from "./componentCatalog.js";
|
|
13
|
+
// Dash patterns are SVG stroke-dasharray strings.
|
|
14
|
+
export const DASH_PATTERNS = { dashed: "6 4", dotted: "1 3" };
|
|
15
|
+
export const EDGE_STROKE_WIDTH = 1.5;
|
|
16
|
+
export const BUS_STROKE_WIDTH = 3;
|
|
17
|
+
// Anything at least this heavy reads as a bus line.
|
|
18
|
+
const BUS_MIN_WIDTH = 2.5;
|
|
19
|
+
export const EDGE_SEMANTICS = {
|
|
20
|
+
sync: {
|
|
21
|
+
label: "Sync",
|
|
22
|
+
hint: "Request / response call",
|
|
23
|
+
dashed: false,
|
|
24
|
+
dashPattern: null,
|
|
25
|
+
strokeWidth: EDGE_STROKE_WIDTH,
|
|
26
|
+
},
|
|
27
|
+
async: {
|
|
28
|
+
label: "Async",
|
|
29
|
+
hint: "Fire-and-forget, event or callback",
|
|
30
|
+
dashed: true,
|
|
31
|
+
dashPattern: DASH_PATTERNS.dashed,
|
|
32
|
+
strokeWidth: EDGE_STROKE_WIDTH,
|
|
33
|
+
},
|
|
34
|
+
fallback: {
|
|
35
|
+
label: "Fallback",
|
|
36
|
+
hint: "Retry, fallback or optional path",
|
|
37
|
+
dashed: true,
|
|
38
|
+
dashPattern: DASH_PATTERNS.dotted,
|
|
39
|
+
strokeWidth: 1.25,
|
|
40
|
+
},
|
|
41
|
+
bus: {
|
|
42
|
+
label: "Bus",
|
|
43
|
+
hint: "Message bus or stream",
|
|
44
|
+
dashed: false,
|
|
45
|
+
dashPattern: null,
|
|
46
|
+
strokeWidth: BUS_STROKE_WIDTH,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export const EDGE_SEMANTIC_ORDER = ["sync", "async", "fallback", "bus"];
|
|
50
|
+
export const semanticFromStyle = (style) => {
|
|
51
|
+
if (style?.dashed) {
|
|
52
|
+
return style.dashPattern === DASH_PATTERNS.dotted ? "fallback" : "async";
|
|
53
|
+
}
|
|
54
|
+
return (style?.strokeWidth ?? EDGE_STROKE_WIDTH) >= BUS_MIN_WIDTH ? "bus" : "sync";
|
|
55
|
+
};
|
|
56
|
+
export const semanticStyle = (semantic) => {
|
|
57
|
+
const spec = EDGE_SEMANTICS[semantic];
|
|
58
|
+
return {
|
|
59
|
+
dashed: spec.dashed,
|
|
60
|
+
dashPattern: spec.dashPattern ?? undefined,
|
|
61
|
+
strokeWidth: spec.strokeWidth,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const isEdgeSemantic = (value) => typeof value === "string" && EDGE_SEMANTIC_ORDER.includes(value);
|
|
65
|
+
// Message-broker-ish components: connecting to one of these is what turns an
|
|
66
|
+
// edge into a bus line automatically.
|
|
67
|
+
export const isBusComponentType = (type) => {
|
|
68
|
+
if (!type)
|
|
69
|
+
return false;
|
|
70
|
+
const def = getDiagramComponent(type);
|
|
71
|
+
if (!def)
|
|
72
|
+
return false;
|
|
73
|
+
return def.category === "messaging" || type === "net.queue" || type === "mq.kafka";
|
|
74
|
+
};
|
|
75
|
+
// True when the edge still carries the default look — nothing the user chose.
|
|
76
|
+
// Auto-notation only ever upgrades an untouched edge.
|
|
77
|
+
export const isDefaultEdgeStyle = (style) => !style?.dashed && (style?.strokeWidth === undefined || style.strokeWidth === EDGE_STROKE_WIDTH);
|
|
78
|
+
//# sourceMappingURL=edgeSemantics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edgeSemantics.js","sourceRoot":"","sources":["../../src/diagram/edgeSemantics.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yEAAyE;AACzE,EAAE;AACF,6DAA6D;AAC7D,+DAA+D;AAC/D,wEAAwE;AACxE,4EAA4E;AAC5E,EAAE;AACF,uEAAuE;AACvE,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D,kDAAkD;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAW,CAAC;AAEvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,oDAAoD;AACpD,MAAM,aAAa,GAAG,GAAG,CAAC;AAU1B,MAAM,CAAC,MAAM,cAAc,GAA2C;IACpE,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,yBAAyB;QAC/B,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,iBAAiB;KAC/B;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,oCAAoC;QAC1C,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,aAAa,CAAC,MAAM;QACjC,WAAW,EAAE,iBAAiB;KAC/B;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,kCAAkC;QACxC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,aAAa,CAAC,MAAM;QACjC,WAAW,EAAE,IAAI;KAClB;IACD,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AAI,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,UAAU,CAAC;AACrF,CAAC,CAAC;AAEF,8EAA8E;AAC9E,sDAAsD;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAiC,EAAW,EAAE,CAC/E,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DiagramDocument, DiagramNode } from "./schema.js";
|
|
2
|
+
export type LayoutAlgorithm = "layered" | "force" | "tree" | "radial";
|
|
3
|
+
export type LayoutDirection = "DOWN" | "RIGHT" | "UP" | "LEFT";
|
|
4
|
+
export interface LayoutOptions {
|
|
5
|
+
direction?: LayoutDirection;
|
|
6
|
+
nodeIds?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ElkPointLike {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ElkEdgeSectionLike {
|
|
13
|
+
startPoint?: ElkPointLike;
|
|
14
|
+
endPoint?: ElkPointLike;
|
|
15
|
+
bendPoints?: ElkPointLike[];
|
|
16
|
+
}
|
|
17
|
+
export interface ElkEdgeLike {
|
|
18
|
+
id: string;
|
|
19
|
+
sources: string[];
|
|
20
|
+
targets: string[];
|
|
21
|
+
sections?: ElkEdgeSectionLike[];
|
|
22
|
+
}
|
|
23
|
+
export interface ElkGraphLike {
|
|
24
|
+
id: string;
|
|
25
|
+
layoutOptions?: Record<string, string>;
|
|
26
|
+
children?: ElkGraphLike[];
|
|
27
|
+
edges?: ElkEdgeLike[];
|
|
28
|
+
x?: number;
|
|
29
|
+
y?: number;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const layoutOptionsFor: (algorithm: LayoutAlgorithm, direction: LayoutDirection) => Record<string, string>;
|
|
34
|
+
export interface FlatElkGraph {
|
|
35
|
+
graph: ElkGraphLike;
|
|
36
|
+
layoutNodes: DiagramNode[];
|
|
37
|
+
}
|
|
38
|
+
export declare const buildElkGraph: (doc: DiagramDocument, algorithm: LayoutAlgorithm, options?: LayoutOptions) => FlatElkGraph;
|
|
39
|
+
export declare const applyElkPositions: (built: FlatElkGraph, result: ElkGraphLike, options?: LayoutOptions) => Record<string, {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}>;
|
|
43
|
+
export interface RoutedEdge {
|
|
44
|
+
waypoints: Array<{
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}>;
|
|
48
|
+
sourceAnchor?: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
};
|
|
52
|
+
targetAnchor?: {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface DetailedLayout {
|
|
58
|
+
positions: Record<string, {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
}>;
|
|
62
|
+
sizes: Record<string, {
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
}>;
|
|
66
|
+
edges: Record<string, RoutedEdge>;
|
|
67
|
+
}
|
|
68
|
+
export declare const buildHierarchicalElkGraph: (doc: DiagramDocument, algorithm: LayoutAlgorithm, options?: LayoutOptions) => ElkGraphLike;
|
|
69
|
+
export declare const applyHierarchicalElkResult: (result: ElkGraphLike) => DetailedLayout;
|
|
70
|
+
export declare const applyDetailedLayout: (doc: DiagramDocument, layout: DetailedLayout) => DiagramDocument;
|
|
71
|
+
export interface GridLayoutOptions {
|
|
72
|
+
columns?: number;
|
|
73
|
+
gap?: number;
|
|
74
|
+
origin?: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare const gridLayout: (doc: DiagramDocument, options?: GridLayoutOptions) => DiagramDocument;
|
|
80
|
+
//# sourceMappingURL=elkGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elkGraph.d.ts","sourceRoot":"","sources":["../../src/diagram/elkGraph.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;IAG5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC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AAA;KAAE,CAAC,CAAC;IACzD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAKD,eAAO,MAAM,yBAAyB,GACpC,KAAK,eAAe,EACpB,WAAW,eAAe,EAC1B,UAAS,aAAkB,KAC1B,YAkDF,CAAC;AAMF,eAAO,MAAM,0BAA0B,GAAI,QAAQ,YAAY,KAAG,cAoEjE,CAAC;AAOF,eAAO,MAAM,mBAAmB,GAAI,KAAK,eAAe,EAAE,QAAQ,cAAc,KAAG,eAyBlF,CAAC;AAIF,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;AAKD,eAAO,MAAM,UAAU,GAAI,KAAK,eAAe,EAAE,UAAS,iBAAsB,KAAG,eA+DlF,CAAC"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
export const layoutOptionsFor = (algorithm, direction) => {
|
|
2
|
+
switch (algorithm) {
|
|
3
|
+
case "force":
|
|
4
|
+
return { "elk.algorithm": "force", "elk.spacing.nodeNode": "70" };
|
|
5
|
+
case "radial":
|
|
6
|
+
return { "elk.algorithm": "radial", "elk.spacing.nodeNode": "60" };
|
|
7
|
+
case "tree":
|
|
8
|
+
return { "elk.algorithm": "mrtree", "elk.direction": direction, "elk.spacing.nodeNode": "45" };
|
|
9
|
+
case "layered":
|
|
10
|
+
default:
|
|
11
|
+
return {
|
|
12
|
+
"elk.algorithm": "layered",
|
|
13
|
+
"elk.direction": direction,
|
|
14
|
+
"elk.layered.spacing.nodeNodeBetweenLayers": "70",
|
|
15
|
+
"elk.spacing.nodeNode": "45",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Only top-level nodes are laid out; children ride with their container.
|
|
20
|
+
export const buildElkGraph = (doc, algorithm, options = {}) => {
|
|
21
|
+
const direction = options.direction ?? "DOWN";
|
|
22
|
+
const topLevel = doc.nodes.filter((node) => !node.parentId);
|
|
23
|
+
const subset = options.nodeIds && options.nodeIds.length > 1 ? new Set(options.nodeIds) : undefined;
|
|
24
|
+
const layoutNodes = subset ? topLevel.filter((node) => subset.has(node.id)) : topLevel;
|
|
25
|
+
const layoutIds = new Set(layoutNodes.map((node) => node.id));
|
|
26
|
+
return {
|
|
27
|
+
layoutNodes,
|
|
28
|
+
graph: {
|
|
29
|
+
id: "root",
|
|
30
|
+
layoutOptions: layoutOptionsFor(algorithm, direction),
|
|
31
|
+
children: layoutNodes.map((node) => ({
|
|
32
|
+
id: node.id,
|
|
33
|
+
width: node.size.width,
|
|
34
|
+
height: node.size.height,
|
|
35
|
+
})),
|
|
36
|
+
// Only edges whose BOTH ends are laid-out nodes participate; free "Line"
|
|
37
|
+
// components (point endpoints) are skipped.
|
|
38
|
+
edges: doc.edges
|
|
39
|
+
.filter((edge) => edge.source && edge.target && layoutIds.has(edge.source) && layoutIds.has(edge.target))
|
|
40
|
+
.map((edge) => ({ id: edge.id, sources: [edge.source], targets: [edge.target] })),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
// Positions keyed by node id. A selection-only layout stays anchored where the
|
|
45
|
+
// selection already was so it doesn't jump to the ELK origin.
|
|
46
|
+
export const applyElkPositions = (built, result, options = {}) => {
|
|
47
|
+
const positions = {};
|
|
48
|
+
for (const child of result.children ?? []) {
|
|
49
|
+
if (typeof child.x === "number" && typeof child.y === "number") {
|
|
50
|
+
positions[child.id] = { x: Math.round(child.x), y: Math.round(child.y) };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const subset = options.nodeIds && options.nodeIds.length > 1;
|
|
54
|
+
if (subset) {
|
|
55
|
+
const laidOut = built.layoutNodes.filter((node) => positions[node.id]);
|
|
56
|
+
if (laidOut.length > 0) {
|
|
57
|
+
const origMinX = Math.min(...laidOut.map((node) => node.position.x));
|
|
58
|
+
const origMinY = Math.min(...laidOut.map((node) => node.position.y));
|
|
59
|
+
const resMinX = Math.min(...laidOut.map((node) => positions[node.id].x));
|
|
60
|
+
const resMinY = Math.min(...laidOut.map((node) => positions[node.id].y));
|
|
61
|
+
const dx = origMinX - resMinX;
|
|
62
|
+
const dy = origMinY - resMinY;
|
|
63
|
+
for (const id of Object.keys(positions)) {
|
|
64
|
+
positions[id] = { x: positions[id].x + dx, y: positions[id].y + dy };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return positions;
|
|
69
|
+
};
|
|
70
|
+
// Full HIERARCHICAL graph for an AI/MCP-generated diagram: children are nested
|
|
71
|
+
// under their container (`parentId`) so ELK lays them out INSIDE and SIZES the
|
|
72
|
+
// container to fit; edges are routed orthogonally around nodes.
|
|
73
|
+
export const buildHierarchicalElkGraph = (doc, algorithm, options = {}) => {
|
|
74
|
+
const direction = options.direction ?? "DOWN";
|
|
75
|
+
const nodeById = new Map(doc.nodes.map((node) => [node.id, node]));
|
|
76
|
+
const childrenOf = new Map();
|
|
77
|
+
const roots = [];
|
|
78
|
+
for (const node of doc.nodes) {
|
|
79
|
+
if (node.parentId && nodeById.has(node.parentId)) {
|
|
80
|
+
const list = childrenOf.get(node.parentId) ?? [];
|
|
81
|
+
list.push(node);
|
|
82
|
+
childrenOf.set(node.parentId, list);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
roots.push(node);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Inner layout for a container: lay children out and pad (top pad leaves
|
|
89
|
+
// room for the container's title so children don't sit under it).
|
|
90
|
+
const containerOptions = {
|
|
91
|
+
"elk.algorithm": "layered",
|
|
92
|
+
"elk.direction": direction,
|
|
93
|
+
"elk.layered.spacing.nodeNodeBetweenLayers": "60",
|
|
94
|
+
"elk.spacing.nodeNode": "45",
|
|
95
|
+
"elk.padding": "[top=48,left=28,bottom=28,right=28]",
|
|
96
|
+
};
|
|
97
|
+
const toElk = (node) => {
|
|
98
|
+
const kids = childrenOf.get(node.id) ?? [];
|
|
99
|
+
if (kids.length > 0) {
|
|
100
|
+
// Omit width/height so ELK sizes the container to fit its children.
|
|
101
|
+
return { id: node.id, layoutOptions: containerOptions, children: kids.map(toElk) };
|
|
102
|
+
}
|
|
103
|
+
return { id: node.id, width: node.size.width, height: node.size.height };
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
id: "root",
|
|
107
|
+
layoutOptions: {
|
|
108
|
+
...layoutOptionsFor(algorithm, direction),
|
|
109
|
+
"elk.edgeRouting": "ORTHOGONAL",
|
|
110
|
+
"elk.spacing.nodeNode": "60",
|
|
111
|
+
"elk.layered.spacing.nodeNodeBetweenLayers": "90",
|
|
112
|
+
"elk.layered.spacing.edgeNodeBetweenLayers": "30",
|
|
113
|
+
// Let edges cross container boundaries and be routed together.
|
|
114
|
+
"elk.hierarchyHandling": "INCLUDE_CHILDREN",
|
|
115
|
+
},
|
|
116
|
+
children: roots.map(toElk),
|
|
117
|
+
edges: doc.edges
|
|
118
|
+
.filter((edge) => edge.source && edge.target && nodeById.has(edge.source) && nodeById.has(edge.target))
|
|
119
|
+
.map((edge) => ({ id: edge.id, sources: [edge.source], targets: [edge.target] })),
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
// Walk the ELK result tree, accumulating each node's ABSOLUTE offset: node
|
|
123
|
+
// positions/edges from ELK are relative to their container, so the
|
|
124
|
+
// container's absolute origin is added back to recover absolute coordinates
|
|
125
|
+
// for anchors and waypoints. Positions stay relative to the parent.
|
|
126
|
+
export const applyHierarchicalElkResult = (result) => {
|
|
127
|
+
const positions = {};
|
|
128
|
+
const sizes = {};
|
|
129
|
+
const absBounds = new Map();
|
|
130
|
+
const rawEdges = [];
|
|
131
|
+
const walk = (node, absX, absY) => {
|
|
132
|
+
for (const edge of node.edges ?? []) {
|
|
133
|
+
const section = edge.sections?.[0];
|
|
134
|
+
if (!section)
|
|
135
|
+
continue;
|
|
136
|
+
const toAbs = (p) => ({
|
|
137
|
+
x: Math.round(absX + p.x),
|
|
138
|
+
y: Math.round(absY + p.y),
|
|
139
|
+
});
|
|
140
|
+
rawEdges.push({
|
|
141
|
+
id: edge.id,
|
|
142
|
+
sourceId: edge.sources?.[0],
|
|
143
|
+
targetId: edge.targets?.[0],
|
|
144
|
+
waypoints: (section.bendPoints ?? []).map(toAbs),
|
|
145
|
+
start: section.startPoint ? toAbs(section.startPoint) : undefined,
|
|
146
|
+
end: section.endPoint ? toAbs(section.endPoint) : undefined,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
for (const child of node.children ?? []) {
|
|
150
|
+
const rx = child.x ?? 0;
|
|
151
|
+
const ry = child.y ?? 0;
|
|
152
|
+
const cx = absX + rx;
|
|
153
|
+
const cy = absY + ry;
|
|
154
|
+
positions[child.id] = { x: Math.round(rx), y: Math.round(ry) };
|
|
155
|
+
if (typeof child.width === "number" && typeof child.height === "number") {
|
|
156
|
+
sizes[child.id] = { width: Math.round(child.width), height: Math.round(child.height) };
|
|
157
|
+
absBounds.set(child.id, { x: cx, y: cy, w: child.width, h: child.height });
|
|
158
|
+
}
|
|
159
|
+
walk(child, cx, cy);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
walk(result, 0, 0);
|
|
163
|
+
const clamp01 = (n) => Math.min(1, Math.max(0, n));
|
|
164
|
+
const toAnchor = (point, id) => {
|
|
165
|
+
const bounds = id ? absBounds.get(id) : undefined;
|
|
166
|
+
if (!point || !bounds || bounds.w <= 0 || bounds.h <= 0)
|
|
167
|
+
return undefined;
|
|
168
|
+
return {
|
|
169
|
+
x: Math.round(clamp01((point.x - bounds.x) / bounds.w) * 1000) / 1000,
|
|
170
|
+
y: Math.round(clamp01((point.y - bounds.y) / bounds.h) * 1000) / 1000,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
const edges = {};
|
|
174
|
+
for (const edge of rawEdges) {
|
|
175
|
+
edges[edge.id] = {
|
|
176
|
+
waypoints: edge.waypoints,
|
|
177
|
+
sourceAnchor: toAnchor(edge.start, edge.sourceId),
|
|
178
|
+
targetAnchor: toAnchor(edge.end, edge.targetId),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return { positions, sizes, edges };
|
|
182
|
+
};
|
|
183
|
+
// Bake a detailed layout onto the document: ELK positions + container sizes
|
|
184
|
+
// on nodes; STRAIGHT routing through ELK's bend points with both ends PINNED
|
|
185
|
+
// to ELK's exact connection points on edges, so the whole path is fixed,
|
|
186
|
+
// axis-aligned geometry (identical at every zoom — the desktop's floating
|
|
187
|
+
// router would otherwise re-route on every view revalidate).
|
|
188
|
+
export const applyDetailedLayout = (doc, layout) => {
|
|
189
|
+
if (Object.keys(layout.positions).length === 0)
|
|
190
|
+
return doc;
|
|
191
|
+
return {
|
|
192
|
+
...doc,
|
|
193
|
+
nodes: doc.nodes.map((node) => {
|
|
194
|
+
const position = layout.positions[node.id];
|
|
195
|
+
const size = layout.sizes[node.id];
|
|
196
|
+
let next = node;
|
|
197
|
+
if (position)
|
|
198
|
+
next = { ...next, position };
|
|
199
|
+
if (size)
|
|
200
|
+
next = { ...next, size };
|
|
201
|
+
return next;
|
|
202
|
+
}),
|
|
203
|
+
edges: doc.edges.map((edge) => {
|
|
204
|
+
const routed = layout.edges[edge.id];
|
|
205
|
+
// Only re-route edges ELK actually laid out (both ends are nodes).
|
|
206
|
+
if (!routed || !edge.source || !edge.target)
|
|
207
|
+
return edge;
|
|
208
|
+
return {
|
|
209
|
+
...edge,
|
|
210
|
+
routing: "straight",
|
|
211
|
+
waypoints: routed.waypoints.length > 0 ? routed.waypoints : undefined,
|
|
212
|
+
sourceAnchor: routed.sourceAnchor,
|
|
213
|
+
targetAnchor: routed.targetAnchor,
|
|
214
|
+
};
|
|
215
|
+
}),
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
// Deterministic grid for hosts without elkjs: top-level nodes in reading
|
|
219
|
+
// order, cell size = the largest node, children of a container placed inside
|
|
220
|
+
// it in a sub-grid and the container sized to fit.
|
|
221
|
+
export const gridLayout = (doc, options = {}) => {
|
|
222
|
+
const gap = options.gap ?? 48;
|
|
223
|
+
const origin = options.origin ?? { x: 80, y: 80 };
|
|
224
|
+
const nodeById = new Map(doc.nodes.map((node) => [node.id, node]));
|
|
225
|
+
const childrenOf = new Map();
|
|
226
|
+
const roots = [];
|
|
227
|
+
for (const node of doc.nodes) {
|
|
228
|
+
if (node.parentId && nodeById.has(node.parentId)) {
|
|
229
|
+
const list = childrenOf.get(node.parentId) ?? [];
|
|
230
|
+
list.push(node);
|
|
231
|
+
childrenOf.set(node.parentId, list);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
roots.push(node);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const placed = new Map();
|
|
238
|
+
// Lays `nodes` out in a grid starting at (0,0) relative to their parent and
|
|
239
|
+
// returns the bounding size. Containers are laid out recursively first so
|
|
240
|
+
// their size is known when they take a grid cell.
|
|
241
|
+
const layoutGroup = (nodes, padTop, padSide) => {
|
|
242
|
+
const sized = nodes.map((node) => {
|
|
243
|
+
const kids = childrenOf.get(node.id) ?? [];
|
|
244
|
+
if (kids.length === 0)
|
|
245
|
+
return { node, width: node.size.width, height: node.size.height };
|
|
246
|
+
const inner = layoutGroup(kids, 48, 28);
|
|
247
|
+
return { node, width: inner.width, height: inner.height };
|
|
248
|
+
});
|
|
249
|
+
const columns = options.columns ?? Math.max(1, Math.ceil(Math.sqrt(sized.length)));
|
|
250
|
+
const cellW = Math.max(...sized.map((entry) => entry.width));
|
|
251
|
+
const cellH = Math.max(...sized.map((entry) => entry.height));
|
|
252
|
+
sized.forEach((entry, index) => {
|
|
253
|
+
const col = index % columns;
|
|
254
|
+
const row = Math.floor(index / columns);
|
|
255
|
+
placed.set(entry.node.id, {
|
|
256
|
+
...entry.node,
|
|
257
|
+
position: { x: padSide + col * (cellW + gap), y: padTop + row * (cellH + gap) },
|
|
258
|
+
size: { width: entry.width, height: entry.height },
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
const rows = Math.ceil(sized.length / columns);
|
|
262
|
+
return {
|
|
263
|
+
width: padSide * 2 + columns * cellW + (columns - 1) * gap,
|
|
264
|
+
height: padTop + padSide + rows * cellH + (rows - 1) * gap,
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
if (roots.length > 0)
|
|
268
|
+
layoutGroup(roots, 0, 0);
|
|
269
|
+
return {
|
|
270
|
+
...doc,
|
|
271
|
+
nodes: doc.nodes.map((node) => {
|
|
272
|
+
const next = placed.get(node.id) ?? node;
|
|
273
|
+
if (next.parentId)
|
|
274
|
+
return next;
|
|
275
|
+
return { ...next, position: { x: next.position.x + origin.x, y: next.position.y + origin.y } };
|
|
276
|
+
}),
|
|
277
|
+
// Drop stale routing — positions changed.
|
|
278
|
+
edges: doc.edges.map((edge) => edge.source && edge.target
|
|
279
|
+
? { ...edge, waypoints: undefined, sourceAnchor: undefined, targetAnchor: undefined }
|
|
280
|
+
: edge),
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
//# sourceMappingURL=elkGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elkGraph.js","sourceRoot":"","sources":["../../src/diagram/elkGraph.ts"],"names":[],"mappings":"AAiDA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,SAA0B,EAC1B,SAA0B,EACF,EAAE;IAC1B,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;QACpE,KAAK,QAAQ;YACX,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;QACrE,KAAK,MAAM;YACT,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,sB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C5B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;YACzC,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAC/B,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;QACjG,CAAC,CAAC;QACF,0CAA0C;QAC1C,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC5B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;YACxB,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;YACrF,CAAC,CAAC,IAAI,CACT;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./schema.js";
|
|
2
|
+
export { migrateDocument } from "./migrations.js";
|
|
3
|
+
export * from "./componentCatalog.js";
|
|
4
|
+
export * from "./edgeSemantics.js";
|
|
5
|
+
export { normalizeDiagramStyle, normalizeDiagramStyles } from "./normalize.js";
|
|
6
|
+
export * from "./elkGraph.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagram/index.ts"],"names":[],"mappings":"AAMA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The diagram document contract — schema + validator + migrations, the
|
|
2
|
+
// serialisable component catalog, edge notation, style normalisation and the
|
|
3
|
+
// pure ELK layout builder/applier. One source for the desktop studio, the
|
|
4
|
+
// MCP server and the backend. CSP-safe throughout: no zod, no ajv, no
|
|
5
|
+
// `new Function`, no Node built-ins, no elkjs (this code runs in the Electron
|
|
6
|
+
// renderer; hosts bring their own elkjs).
|
|
7
|
+
export * from "./schema.js";
|
|
8
|
+
export { migrateDocument } from "./migrations.js";
|
|
9
|
+
export * from "./componentCatalog.js";
|
|
10
|
+
export * from "./edgeSemantics.js";
|
|
11
|
+
export { normalizeDiagramStyle, normalizeDiagramStyles } from "./normalize.js";
|
|
12
|
+
export * from "./elkGraph.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diagram/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,6EAA6E;AAC7E,0EAA0E;AAC1E,sEAAsE;AACtE,8EAA8E;AAC9E,0CAA0C;AAC1C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/diagram/migrations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAwC,MAAM,aAAa,CAAC;AASzF,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,KAAG,eA4B9C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Forward migration of older persisted documents up to the current
|
|
2
|
+
// SCHEMA_VERSION. Empty for v1; each future schema bump registers a
|
|
3
|
+
// vN -> vN+1 step here. A schema bump therefore ships in core FIRST — every
|
|
4
|
+
// host (desktop, MCP, backend) then migrates identically.
|
|
5
|
+
import { parseDiagramDocument, SCHEMA_VERSION } from "./schema.js";
|
|
6
|
+
// Keyed by the version a step upgrades FROM (e.g. 1 transforms v1 -> v2).
|
|
7
|
+
const MIGRATIONS = {
|
|
8
|
+
// 1: (doc) => ({ ...doc, schemaVersion: 2, /* ...transform... */ }),
|
|
9
|
+
};
|
|
10
|
+
export const migrateDocument = (raw) => {
|
|
11
|
+
if (typeof raw !== "object" || raw === null) {
|
|
12
|
+
throw new Error("Cannot migrate: document is not an object");
|
|
13
|
+
}
|
|
14
|
+
let doc = raw;
|
|
15
|
+
let version = typeof doc.schemaVersion === "number" ? doc.schemaVersion : 0;
|
|
16
|
+
while (version < SCHEMA_VERSION) {
|
|
17
|
+
const step = MIGRATIONS[version];
|
|
18
|
+
if (!step) {
|
|
19
|
+
throw new Error(`No migration registered to upgrade from schemaVersion ${version}`);
|
|
20
|
+
}
|
|
21
|
+
doc = step(doc);
|
|
22
|
+
const next = typeof doc.schemaVersion === "number" ? doc.schemaVersion : version + 1;
|
|
23
|
+
if (next <= version) {
|
|
24
|
+
throw new Error(`Migration from schemaVersion ${version} did not advance the version`);
|
|
25
|
+
}
|
|
26
|
+
version = next;
|
|
27
|
+
}
|
|
28
|
+
if (version > SCHEMA_VERSION) {
|
|
29
|
+
throw new Error(`Document schemaVersion ${version} is newer than supported (${SCHEMA_VERSION}); update the app`);
|
|
30
|
+
}
|
|
31
|
+
return parseDiagramDocument(doc);
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/diagram/migrations.ts"],"names":[],"mappings":"AAA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,CAAC;IAED,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DiagramDocument, DiagramStyle } from "./schema.js";
|
|
2
|
+
export declare const normalizeDiagramStyle: (style: unknown) => DiagramStyle | undefined;
|
|
3
|
+
export declare const normalizeDiagramStyles: (doc: DiagramDocument) => DiagramDocument;
|
|
4
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/diagram/normalize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AAY3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,YAAY,GAAG,SAyBrE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,KAAG,eAY5D,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const toTokenRef = (value) => {
|
|
2
|
+
if (typeof value === "string" && value.trim())
|
|
3
|
+
return { raw: value.trim() };
|
|
4
|
+
if (value && typeof value === "object") {
|
|
5
|
+
const ref = value;
|
|
6
|
+
if (typeof ref.raw === "string" && ref.raw.trim())
|
|
7
|
+
return { raw: ref.raw.trim() };
|
|
8
|
+
if (typeof ref.token === "string" && ref.token.trim())
|
|
9
|
+
return { token: ref.token.trim() };
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
};
|
|
13
|
+
export const normalizeDiagramStyle = (style) => {
|
|
14
|
+
if (!style || typeof style !== "object")
|
|
15
|
+
return undefined;
|
|
16
|
+
const s = style;
|
|
17
|
+
const out = {};
|
|
18
|
+
const fill = toTokenRef(s.fill);
|
|
19
|
+
const stroke = toTokenRef(s.stroke);
|
|
20
|
+
const textColor = toTokenRef(s.textColor);
|
|
21
|
+
if (fill)
|
|
22
|
+
out.fill = fill;
|
|
23
|
+
if (stroke)
|
|
24
|
+
out.stroke = stroke;
|
|
25
|
+
if (textColor)
|
|
26
|
+
out.textColor = textColor;
|
|
27
|
+
if (typeof s.strokeWidth === "number")
|
|
28
|
+
out.strokeWidth = s.strokeWidth;
|
|
29
|
+
if (typeof s.radius === "number")
|
|
30
|
+
out.radius = s.radius;
|
|
31
|
+
if (typeof s.rounded === "boolean")
|
|
32
|
+
out.rounded = s.rounded;
|
|
33
|
+
if (typeof s.dashed === "boolean")
|
|
34
|
+
out.dashed = s.dashed;
|
|
35
|
+
if (typeof s.dashPattern === "string")
|
|
36
|
+
out.dashPattern = s.dashPattern;
|
|
37
|
+
if (typeof s.fontSize === "number")
|
|
38
|
+
out.fontSize = s.fontSize;
|
|
39
|
+
if (typeof s.fontWeight === "number")
|
|
40
|
+
out.fontWeight = s.fontWeight;
|
|
41
|
+
if (typeof s.fontFamily === "string")
|
|
42
|
+
out.fontFamily = s.fontFamily;
|
|
43
|
+
if (typeof s.fontStyle === "number")
|
|
44
|
+
out.fontStyle = s.fontStyle;
|
|
45
|
+
if (s.align === "left" || s.align === "center" || s.align === "right")
|
|
46
|
+
out.align = s.align;
|
|
47
|
+
if (s.verticalAlign === "top" || s.verticalAlign === "middle" || s.verticalAlign === "bottom")
|
|
48
|
+
out.verticalAlign = s.verticalAlign;
|
|
49
|
+
if (typeof s.shadow === "boolean")
|
|
50
|
+
out.shadow = s.shadow;
|
|
51
|
+
if (typeof s.opacity === "number")
|
|
52
|
+
out.opacity = s.opacity;
|
|
53
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
54
|
+
};
|
|
55
|
+
export const normalizeDiagramStyles = (doc) => ({
|
|
56
|
+
...doc,
|
|
57
|
+
nodes: doc.nodes.map((node) => ({
|
|
58
|
+
...node,
|
|
59
|
+
// Coerce rotation to a number (the model may omit it or emit a string).
|
|
60
|
+
rotation: typeof node.rotation === "number" ? node.rotation : undefined,
|
|
61
|
+
style: normalizeDiagramStyle(node.style),
|
|
62
|
+
})),
|
|
63
|
+
edges: doc.edges.map((edge) => ({
|
|
64
|
+
...edge,
|
|
65
|
+
style: normalizeDiagramStyle(edge.style),
|
|
66
|
+
})),
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=normalize.js.map
|