flowspec-mcp 5.4.0 → 5.5.1
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/dist/analysis/analysisUtils.d.ts +36 -0
- package/dist/analysis/analysisUtils.js +284 -0
- package/dist/analysis/analysisUtils.js.map +1 -0
- package/dist/db.js +19 -3
- package/dist/db.js.map +1 -1
- package/dist/export/yamlExporter.d.ts +6 -0
- package/dist/export/yamlExporter.js +155 -0
- package/dist/export/yamlExporter.js.map +1 -0
- package/dist/import/yamlImporter.d.ts +22 -0
- package/dist/import/yamlImporter.js +227 -0
- package/dist/import/yamlImporter.js.map +1 -0
- package/dist/index.js +0 -0
- package/dist/layout/semanticLayout.d.ts +24 -0
- package/dist/layout/semanticLayout.js +233 -0
- package/dist/layout/semanticLayout.js.map +1 -0
- package/dist/resources/selection.d.ts +5 -0
- package/dist/resources/selection.js +88 -0
- package/dist/resources/selection.js.map +1 -0
- package/dist/server.js +29 -24
- package/dist/server.js.map +1 -1
- package/dist/tools/captureScreen.d.ts +48 -0
- package/dist/tools/captureScreen.js +135 -0
- package/dist/tools/captureScreen.js.map +1 -0
- package/dist/tools/createNode.d.ts +2 -2
- package/dist/tools/createSubview.d.ts +50 -0
- package/dist/tools/createSubview.js +29 -0
- package/dist/tools/createSubview.js.map +1 -0
- package/dist/tools/deleteSubview.d.ts +24 -0
- package/dist/tools/deleteSubview.js +19 -0
- package/dist/tools/deleteSubview.js.map +1 -0
- package/dist/tools/generateSpec.d.ts +26 -0
- package/dist/tools/generateSpec.js +336 -0
- package/dist/tools/generateSpec.js.map +1 -0
- package/dist/tools/getYaml.d.ts +21 -0
- package/dist/tools/getYaml.js +23 -0
- package/dist/tools/getYaml.js.map +1 -0
- package/dist/tools/healthCheck.d.ts +8 -0
- package/dist/tools/healthCheck.js +16 -0
- package/dist/tools/healthCheck.js.map +1 -0
- package/dist/tools/importYaml.d.ts +33 -0
- package/dist/tools/importYaml.js +97 -0
- package/dist/tools/importYaml.js.map +1 -0
- package/dist/tools/ingestCodebase.d.ts +27 -0
- package/dist/tools/ingestCodebase.js +516 -0
- package/dist/tools/ingestCodebase.js.map +1 -0
- package/dist/tools/listSubviews.d.ts +21 -0
- package/dist/tools/listSubviews.js +34 -0
- package/dist/tools/listSubviews.js.map +1 -0
- package/dist/tools/smartLayout.d.ts +30 -0
- package/dist/tools/smartLayout.js +74 -0
- package/dist/tools/smartLayout.js.map +1 -0
- package/dist/tools/updateSubview.d.ts +53 -0
- package/dist/tools/updateSubview.js +33 -0
- package/dist/tools/updateSubview.js.map +1 -0
- package/dist/utils/selectionHelper.d.ts +61 -0
- package/dist/utils/selectionHelper.js +111 -0
- package/dist/utils/selectionHelper.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { stringify } from 'yaml';
|
|
2
|
+
/**
|
|
3
|
+
* Exports canvas state to YAML specification optimised for Claude Code.
|
|
4
|
+
* Adapted from web app — uses plain interfaces instead of @xyflow/svelte types.
|
|
5
|
+
*/
|
|
6
|
+
export function exportToYaml(nodes, edges, projectName = 'Untitled Project', screens = []) {
|
|
7
|
+
const exportableNodes = nodes.filter((n) => n.type !== 'image' && n.type !== 'screen');
|
|
8
|
+
const dataPointNodes = exportableNodes.filter((n) => n.type === 'datapoint');
|
|
9
|
+
const componentNodes = exportableNodes.filter((n) => n.type === 'component');
|
|
10
|
+
const transformNodes = exportableNodes.filter((n) => n.type === 'transform');
|
|
11
|
+
const tableNodes = exportableNodes.filter((n) => n.type === 'table');
|
|
12
|
+
const locationMap = buildLocationMap(dataPointNodes, componentNodes, edges);
|
|
13
|
+
// Build node label lookup for screen region export
|
|
14
|
+
const nodeLabelMap = new Map();
|
|
15
|
+
for (const n of exportableNodes) {
|
|
16
|
+
const label = n.data.label ?? 'Untitled';
|
|
17
|
+
nodeLabelMap.set(n.id, { label, type: n.type ?? 'unknown' });
|
|
18
|
+
}
|
|
19
|
+
const spec = {
|
|
20
|
+
version: '1.2.0',
|
|
21
|
+
metadata: {
|
|
22
|
+
projectName,
|
|
23
|
+
exportedAt: new Date().toISOString(),
|
|
24
|
+
nodeCount: exportableNodes.length,
|
|
25
|
+
edgeCount: edges.length,
|
|
26
|
+
},
|
|
27
|
+
dataPoints: dataPointNodes.map((node) => {
|
|
28
|
+
const data = node.data;
|
|
29
|
+
return {
|
|
30
|
+
id: node.id,
|
|
31
|
+
label: data.label,
|
|
32
|
+
type: data.type,
|
|
33
|
+
source: data.source,
|
|
34
|
+
sourceDefinition: data.sourceDefinition,
|
|
35
|
+
constraints: data.constraints,
|
|
36
|
+
locations: locationMap.get(node.id) ?? [],
|
|
37
|
+
};
|
|
38
|
+
}),
|
|
39
|
+
components: componentNodes.map((node) => {
|
|
40
|
+
const data = node.data;
|
|
41
|
+
const result = {
|
|
42
|
+
id: node.id,
|
|
43
|
+
label: data.label,
|
|
44
|
+
displays: data.displays,
|
|
45
|
+
captures: data.captures,
|
|
46
|
+
};
|
|
47
|
+
if (data.wireframeRef) {
|
|
48
|
+
result.wireframeRef = data.wireframeRef;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}),
|
|
52
|
+
transforms: transformNodes.map((node) => {
|
|
53
|
+
const data = node.data;
|
|
54
|
+
return {
|
|
55
|
+
id: node.id,
|
|
56
|
+
type: data.type,
|
|
57
|
+
description: data.description,
|
|
58
|
+
inputs: data.inputs,
|
|
59
|
+
outputs: data.outputs,
|
|
60
|
+
logic: data.logic,
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
dataFlow: edges.filter((e) => {
|
|
64
|
+
return e.data?.edgeType !== 'contains';
|
|
65
|
+
}).map((edge) => {
|
|
66
|
+
const result = {
|
|
67
|
+
from: edge.source,
|
|
68
|
+
to: edge.target,
|
|
69
|
+
edgeType: edge.data?.edgeType ?? 'flows-to',
|
|
70
|
+
};
|
|
71
|
+
if (edge.data?.label) {
|
|
72
|
+
result.label = edge.data.label;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
// Add tables section if table nodes exist
|
|
78
|
+
if (tableNodes.length > 0) {
|
|
79
|
+
spec.tables = tableNodes.map((node) => {
|
|
80
|
+
const data = node.data;
|
|
81
|
+
const result = {
|
|
82
|
+
id: node.id,
|
|
83
|
+
label: data.label,
|
|
84
|
+
sourceType: data.sourceType,
|
|
85
|
+
columns: (data.columns ?? []).map((c) => ({ name: c.name, type: c.type })),
|
|
86
|
+
};
|
|
87
|
+
if (data.endpoint) {
|
|
88
|
+
result.endpoint = data.endpoint;
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Add screens section if screens exist
|
|
94
|
+
if (screens.length > 0) {
|
|
95
|
+
spec.screens = screens.map((sc) => ({
|
|
96
|
+
id: sc.id,
|
|
97
|
+
name: sc.name,
|
|
98
|
+
imageFilename: sc.imageFilename,
|
|
99
|
+
regions: sc.regions.map((r) => {
|
|
100
|
+
const region = {
|
|
101
|
+
id: r.id,
|
|
102
|
+
label: r.label,
|
|
103
|
+
position: {
|
|
104
|
+
x: Math.round(r.position.x * 10) / 10,
|
|
105
|
+
y: Math.round(r.position.y * 10) / 10,
|
|
106
|
+
},
|
|
107
|
+
size: {
|
|
108
|
+
width: Math.round(r.size.width * 10) / 10,
|
|
109
|
+
height: Math.round(r.size.height * 10) / 10,
|
|
110
|
+
},
|
|
111
|
+
elements: r.elementIds.map((eid) => {
|
|
112
|
+
const info = nodeLabelMap.get(eid);
|
|
113
|
+
return {
|
|
114
|
+
nodeId: eid,
|
|
115
|
+
nodeLabel: info?.label ?? 'Missing element',
|
|
116
|
+
nodeType: info?.type ?? 'unknown',
|
|
117
|
+
};
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
120
|
+
if (r.componentNodeId) {
|
|
121
|
+
region.componentNodeId = r.componentNodeId;
|
|
122
|
+
}
|
|
123
|
+
return region;
|
|
124
|
+
}),
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
return stringify(spec, {
|
|
128
|
+
lineWidth: 120,
|
|
129
|
+
indent: 2,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function buildLocationMap(dataPoints, components, edges) {
|
|
133
|
+
const map = new Map();
|
|
134
|
+
for (const dp of dataPoints) {
|
|
135
|
+
map.set(dp.id, []);
|
|
136
|
+
}
|
|
137
|
+
for (const edge of edges) {
|
|
138
|
+
const sourceIsDataPoint = dataPoints.some((n) => n.id === edge.source);
|
|
139
|
+
const targetIsComponent = components.some((n) => n.id === edge.target);
|
|
140
|
+
if (sourceIsDataPoint && targetIsComponent) {
|
|
141
|
+
const locations = map.get(edge.source) ?? [];
|
|
142
|
+
locations.push({ component: edge.target, role: 'output' });
|
|
143
|
+
map.set(edge.source, locations);
|
|
144
|
+
}
|
|
145
|
+
const sourceIsComponent = components.some((n) => n.id === edge.source);
|
|
146
|
+
const targetIsDataPoint = dataPoints.some((n) => n.id === edge.target);
|
|
147
|
+
if (sourceIsComponent && targetIsDataPoint) {
|
|
148
|
+
const locations = map.get(edge.target) ?? [];
|
|
149
|
+
locations.push({ component: edge.source, role: 'input' });
|
|
150
|
+
map.set(edge.target, locations);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return map;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=yamlExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yamlExporter.js","sourceRoot":"","sources":["../../src/export/yamlExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAgGjC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAmB,EACnB,KAAmB,EACnB,cAAsB,kBAAkB,EACxC,UAAoB,EAAE;IAEtB,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,I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CAAC;QAED,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC;QACvE,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC;QAEvE,IAAI,iBAAiB,IAAI,iBAAiB,EAAE,CAAC;YAC3C,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a validated YAML spec back into FlowSpec canvas nodes and edges.
|
|
3
|
+
* Ported from src/lib/import/yamlImporter.ts — uses MCP types, no @xyflow deps.
|
|
4
|
+
* Lenient: uses sensible defaults for missing fields, skips broken edges.
|
|
5
|
+
*/
|
|
6
|
+
import type { CanvasNode, CanvasEdge, Screen } from '../types.js';
|
|
7
|
+
export interface ImportResult {
|
|
8
|
+
nodes: CanvasNode[];
|
|
9
|
+
edges: CanvasEdge[];
|
|
10
|
+
screens: Screen[];
|
|
11
|
+
projectName: string;
|
|
12
|
+
stats: {
|
|
13
|
+
dataPoints: number;
|
|
14
|
+
components: number;
|
|
15
|
+
transforms: number;
|
|
16
|
+
tables: number;
|
|
17
|
+
edges: number;
|
|
18
|
+
skippedEdges: number;
|
|
19
|
+
skippedNodes: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function importFromYaml(spec: Record<string, unknown>): ImportResult;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
export function importFromYaml(spec) {
|
|
2
|
+
const metadata = (spec.metadata ?? {});
|
|
3
|
+
const projectName = metadata.projectName ?? 'Imported Project';
|
|
4
|
+
const rawDataPoints = spec.dataPoints ?? [];
|
|
5
|
+
const rawComponents = spec.components ?? [];
|
|
6
|
+
const rawTransforms = spec.transforms ?? [];
|
|
7
|
+
const rawDataFlow = spec.dataFlow ?? [];
|
|
8
|
+
const rawTables = spec.tables ?? [];
|
|
9
|
+
const nodes = [];
|
|
10
|
+
const seenIds = new Set();
|
|
11
|
+
let skippedNodes = 0;
|
|
12
|
+
// --- DataPoints ---
|
|
13
|
+
for (const dp of rawDataPoints) {
|
|
14
|
+
const id = dp.id;
|
|
15
|
+
if (!id || seenIds.has(id)) {
|
|
16
|
+
skippedNodes++;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
seenIds.add(id);
|
|
20
|
+
nodes.push({
|
|
21
|
+
id,
|
|
22
|
+
type: 'datapoint',
|
|
23
|
+
position: { x: 0, y: 0 },
|
|
24
|
+
data: {
|
|
25
|
+
label: dp.label ?? 'Untitled',
|
|
26
|
+
type: validDataType(dp.type),
|
|
27
|
+
source: validSource(dp.source),
|
|
28
|
+
sourceDefinition: dp.sourceDefinition ?? '',
|
|
29
|
+
constraints: Array.isArray(dp.constraints) ? dp.constraints : []
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// --- Components ---
|
|
34
|
+
for (const comp of rawComponents) {
|
|
35
|
+
const id = comp.id;
|
|
36
|
+
if (!id || seenIds.has(id)) {
|
|
37
|
+
skippedNodes++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
seenIds.add(id);
|
|
41
|
+
const data = {
|
|
42
|
+
label: comp.label ?? 'Untitled Component',
|
|
43
|
+
displays: Array.isArray(comp.displays) ? comp.displays : [],
|
|
44
|
+
captures: Array.isArray(comp.captures) ? comp.captures : []
|
|
45
|
+
};
|
|
46
|
+
if (comp.wireframeRef) {
|
|
47
|
+
data.wireframeRef = comp.wireframeRef;
|
|
48
|
+
}
|
|
49
|
+
nodes.push({ id, type: 'component', position: { x: 0, y: 0 }, data });
|
|
50
|
+
}
|
|
51
|
+
// --- Transforms ---
|
|
52
|
+
for (const tx of rawTransforms) {
|
|
53
|
+
const id = tx.id;
|
|
54
|
+
if (!id || seenIds.has(id)) {
|
|
55
|
+
skippedNodes++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
seenIds.add(id);
|
|
59
|
+
const description = tx.description ?? '';
|
|
60
|
+
const rawLogic = (tx.logic ?? {});
|
|
61
|
+
nodes.push({
|
|
62
|
+
id,
|
|
63
|
+
type: 'transform',
|
|
64
|
+
position: { x: 0, y: 0 },
|
|
65
|
+
data: {
|
|
66
|
+
label: description || 'Untitled Transform',
|
|
67
|
+
type: validLogicType(tx.type),
|
|
68
|
+
description,
|
|
69
|
+
inputs: Array.isArray(tx.inputs) ? tx.inputs : [],
|
|
70
|
+
outputs: Array.isArray(tx.outputs) ? tx.outputs : [],
|
|
71
|
+
logic: {
|
|
72
|
+
type: validLogicContentType(rawLogic.type),
|
|
73
|
+
content: rawLogic.content ?? ''
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// --- Tables ---
|
|
79
|
+
for (const tbl of rawTables) {
|
|
80
|
+
const id = tbl.id;
|
|
81
|
+
if (!id || seenIds.has(id)) {
|
|
82
|
+
skippedNodes++;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
seenIds.add(id);
|
|
86
|
+
const rawColumns = Array.isArray(tbl.columns) ? tbl.columns : [];
|
|
87
|
+
const columns = rawColumns.map((c) => ({
|
|
88
|
+
name: c.name ?? '',
|
|
89
|
+
type: validDataType(c.type)
|
|
90
|
+
}));
|
|
91
|
+
nodes.push({
|
|
92
|
+
id,
|
|
93
|
+
type: 'table',
|
|
94
|
+
position: { x: 0, y: 0 },
|
|
95
|
+
data: {
|
|
96
|
+
label: tbl.label ?? 'Untitled Table',
|
|
97
|
+
sourceType: validTableSourceType(tbl.sourceType),
|
|
98
|
+
columns,
|
|
99
|
+
endpoint: tbl.endpoint ?? ''
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// --- Edges (no markerEnd — visual-only, not needed in canvas_state) ---
|
|
104
|
+
const edges = [];
|
|
105
|
+
let skippedEdges = 0;
|
|
106
|
+
for (const flow of rawDataFlow) {
|
|
107
|
+
const from = flow.from;
|
|
108
|
+
const to = flow.to;
|
|
109
|
+
if (!from || !to || !seenIds.has(from) || !seenIds.has(to)) {
|
|
110
|
+
skippedEdges++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const edgeData = {
|
|
114
|
+
edgeType: validEdgeType(flow.edgeType)
|
|
115
|
+
};
|
|
116
|
+
if (flow.label) {
|
|
117
|
+
edgeData.label = flow.label;
|
|
118
|
+
}
|
|
119
|
+
edges.push({
|
|
120
|
+
id: crypto.randomUUID(),
|
|
121
|
+
source: from,
|
|
122
|
+
target: to,
|
|
123
|
+
type: 'typed',
|
|
124
|
+
data: edgeData
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// --- Screens (import metadata + auto-create screen nodes) ---
|
|
128
|
+
const screens = [];
|
|
129
|
+
const rawScreens = spec.screens ?? [];
|
|
130
|
+
let screenOffsetY = 50;
|
|
131
|
+
for (const rawSc of rawScreens) {
|
|
132
|
+
const screenId = rawSc.id ?? crypto.randomUUID();
|
|
133
|
+
const rawRegions = Array.isArray(rawSc.regions) ? rawSc.regions : [];
|
|
134
|
+
const regions = rawRegions.map((r) => {
|
|
135
|
+
const rawElements = Array.isArray(r.elements) ? r.elements : [];
|
|
136
|
+
return {
|
|
137
|
+
id: r.id ?? crypto.randomUUID(),
|
|
138
|
+
label: r.label,
|
|
139
|
+
position: {
|
|
140
|
+
x: (r.position?.x ?? 10),
|
|
141
|
+
y: (r.position?.y ?? 10)
|
|
142
|
+
},
|
|
143
|
+
size: {
|
|
144
|
+
width: (r.size?.width ?? 20),
|
|
145
|
+
height: (r.size?.height ?? 15)
|
|
146
|
+
},
|
|
147
|
+
elementIds: rawElements
|
|
148
|
+
.map((el) => el.nodeId)
|
|
149
|
+
.filter((eid) => seenIds.has(eid)),
|
|
150
|
+
componentNodeId: r.componentNodeId || undefined
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
const elementCount = regions.reduce((sum, r) => sum + r.elementIds.length, 0);
|
|
154
|
+
screens.push({
|
|
155
|
+
id: screenId,
|
|
156
|
+
name: rawSc.name ?? 'Imported Screen',
|
|
157
|
+
imageUrl: '',
|
|
158
|
+
imageWidth: 1920,
|
|
159
|
+
imageHeight: 1080,
|
|
160
|
+
imageFilename: rawSc.imageFilename,
|
|
161
|
+
regions
|
|
162
|
+
});
|
|
163
|
+
// Auto-create screen node on canvas
|
|
164
|
+
const screenNodeId = crypto.randomUUID();
|
|
165
|
+
nodes.push({
|
|
166
|
+
id: screenNodeId,
|
|
167
|
+
type: 'screen',
|
|
168
|
+
position: { x: 50, y: screenOffsetY },
|
|
169
|
+
data: {
|
|
170
|
+
label: rawSc.name ?? 'Imported Screen',
|
|
171
|
+
screenId,
|
|
172
|
+
regionCount: regions.length,
|
|
173
|
+
elementCount
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
screenOffsetY += 160;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
nodes,
|
|
180
|
+
edges,
|
|
181
|
+
screens,
|
|
182
|
+
projectName,
|
|
183
|
+
stats: {
|
|
184
|
+
dataPoints: nodes.filter((n) => n.type === 'datapoint').length,
|
|
185
|
+
components: nodes.filter((n) => n.type === 'component').length,
|
|
186
|
+
transforms: nodes.filter((n) => n.type === 'transform').length,
|
|
187
|
+
tables: nodes.filter((n) => n.type === 'table').length,
|
|
188
|
+
edges: edges.length,
|
|
189
|
+
skippedEdges,
|
|
190
|
+
skippedNodes
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// --- Validation helpers with defaults ---
|
|
195
|
+
const VALID_DATA_TYPES = new Set(['string', 'number', 'boolean', 'object', 'array']);
|
|
196
|
+
function validDataType(t) {
|
|
197
|
+
return t && VALID_DATA_TYPES.has(t) ? t : 'string';
|
|
198
|
+
}
|
|
199
|
+
const VALID_SOURCES = new Set(['captured', 'inferred']);
|
|
200
|
+
function validSource(s) {
|
|
201
|
+
return s && VALID_SOURCES.has(s) ? s : 'captured';
|
|
202
|
+
}
|
|
203
|
+
const VALID_LOGIC_TYPES = new Set(['formula', 'validation', 'workflow']);
|
|
204
|
+
function validLogicType(t) {
|
|
205
|
+
return t && VALID_LOGIC_TYPES.has(t) ? t : 'formula';
|
|
206
|
+
}
|
|
207
|
+
const VALID_LOGIC_CONTENT_TYPES = new Set(['formula', 'decision_table', 'steps']);
|
|
208
|
+
function validLogicContentType(t) {
|
|
209
|
+
return t && VALID_LOGIC_CONTENT_TYPES.has(t)
|
|
210
|
+
? t
|
|
211
|
+
: 'formula';
|
|
212
|
+
}
|
|
213
|
+
const VALID_TABLE_SOURCE_TYPES = new Set(['database', 'api', 'file', 'manual']);
|
|
214
|
+
function validTableSourceType(t) {
|
|
215
|
+
return t && VALID_TABLE_SOURCE_TYPES.has(t) ? t : 'database';
|
|
216
|
+
}
|
|
217
|
+
const VALID_EDGE_TYPES = new Set([
|
|
218
|
+
'flows-to',
|
|
219
|
+
'derives-from',
|
|
220
|
+
'transforms',
|
|
221
|
+
'validates',
|
|
222
|
+
'contains'
|
|
223
|
+
]);
|
|
224
|
+
function validEdgeType(t) {
|
|
225
|
+
return t && VALID_EDGE_TYPES.has(t) ? t : 'flows-to';
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=yamlImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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GED
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CanvasNode, CanvasEdge } from '../types.js';
|
|
2
|
+
export interface LayoutCommand {
|
|
3
|
+
nodeIds: string[];
|
|
4
|
+
targetBounds: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
arrangement: 'stack' | 'grid' | 'flow' | 'cluster';
|
|
11
|
+
direction?: 'vertical' | 'horizontal';
|
|
12
|
+
}
|
|
13
|
+
export declare function parseNaturalLanguageLayout(command: string, nodes: CanvasNode[], canvasBounds: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}): LayoutCommand | {
|
|
17
|
+
error: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function applySemanticLayout(nodes: CanvasNode[], edges: CanvasEdge[], command: LayoutCommand): Map<string, {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const SUPPORTED_COMMANDS: string[];
|
|
24
|
+
export declare const SUPPORTED_REGIONS: string[];
|